+
+
+ +

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 000000000..8485f6719 --- /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 063/611] 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 0bf6a3716..b6ceb5f0f 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs @@ -24,7 +24,6 @@ public FacebookOptions() 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 ca736f34e..2c00278c7 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs @@ -22,7 +22,6 @@ public GoogleOptions() 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 8c89ef20d..3339cf4cc 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,7 +22,6 @@ public MicrosoftAccountOptions() 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 fa1471bb2..ba689e66b 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs @@ -64,13 +64,5 @@ public OAuthOptions() /// 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 a139f9651..dc2cce996 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -189,12 +189,5 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 dae6fa6b2..85e266326 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs @@ -49,13 +49,5 @@ public TwitterOptions() 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 f5dad7267..5fb3b4caf 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs @@ -48,6 +48,14 @@ public string DisplayName 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 064/611] 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 eb88f4369..5780bccfe 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -107,12 +107,12 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con { 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ protected override async Task HandleRemoteAuthenticateAsync( { 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m // 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 @@ private AuthenticationProperties GetPropertiesFromState(string state) 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunAuthorizationCodeReceive { 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunTokenResponseReceivedEventAs 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 @@ private async Task RunAuthenticationValidatedEve 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 @@ private async Task RunAuthenticationValidatedEve 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 @@ private async Task RunUserInformationReceivedEve 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 @@ private async Task RunAuthenticationFailedEventAsyn 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 8ea5ae42d..312c8c281 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -147,7 +147,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin { // 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 7c4102cf3..6dd298fbc 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -216,7 +216,7 @@ public async Task AuthenticateAsync(AuthenticateContext context) 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 0851b1b5c..8c58d072d 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs @@ -52,12 +52,12 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 065/611] #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 5d2bd6400..c79cbda95 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -5,6 +5,7 @@ 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 @@ public void Configure(IApplicationBuilder app) 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 174032b7b..3d9d32eeb 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 972f3ccc0..01d26fcdf 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -85,10 +85,10 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ dnx . web { 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 ad7dc7e86..e65640fea 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.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 @@ internal class CookieAuthenticationHandler : AuthenticationHandler _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 @@ private async Task ReadCookieTicket() 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 @@ private async Task ReadCookieTicket() { await Options.SessionStore.RemoveAsync(_sessionKey); } - return null; + return AuthenticateResult.Fail("Ticket expired"); } var allowRefresh = ticket.Properties.AllowRefresh ?? true; @@ -99,23 +95,23 @@ private async Task ReadCookieTicket() } // 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 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 e9832862b..7fcf922e5 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -36,13 +36,9 @@ public class JwtBearerEvents : IJwtBearerEvents 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 beb77486f..645cf2cde 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -7,10 +7,12 @@ 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 @@ protected override async Task HandleAuthenticateAsync() } if (receivingTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } // If application retrieved token from somewhere else, use that. @@ -51,7 +53,7 @@ protected override async Task HandleAuthenticateAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() } if (receivedTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } if (_configuration == null && Options.ConfigurationManager != null) @@ -147,7 +149,7 @@ protected override async Task HandleAuthenticateAsync() } if (validatedTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } return AuthenticateResult.Success(ticket); @@ -168,13 +170,13 @@ protected override async Task HandleAuthenticateAsync() } 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 @@ protected override async Task HandleAuthenticateAsync() } if (authenticationFailedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } throw; @@ -201,8 +203,20 @@ protected override async Task HandleAuthenticateAsync() 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 1d9c95d3c..1d36e1437 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -38,20 +38,20 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 5780bccfe..124d8f543 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -307,7 +307,7 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (message == null) { - return AuthenticateResult.Failed("No message."); + return AuthenticateResult.Fail("No message."); } try @@ -336,7 +336,7 @@ protected override async Task HandleRemoteAuthenticateAsync( } else if (messageReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = messageReceivedContext.ProtocolMessage; @@ -345,7 +345,7 @@ protected override async Task HandleRemoteAuthenticateAsync( { // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Failed("Correlation failed."); + return AuthenticateResult.Fail("Correlation failed."); } if (_configuration == null && Options.ConfigurationManager != null) @@ -393,7 +393,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } else if (authenticationFailedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } throw; @@ -459,7 +459,7 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m } else if (authorizationCodeReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeReceivedContext.ProtocolMessage; var code = authorizationCodeReceivedContext.Code; @@ -476,7 +476,7 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m } else if (authorizationCodeRedeemedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeRedeemedContext.ProtocolMessage; @@ -509,7 +509,7 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m } else if (authenticationValidatedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } ticket = authenticationValidatedContext.AuthenticationTicket; @@ -558,7 +558,7 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m } else if (authenticationValidatedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authenticationValidatedContext.ProtocolMessage; ticket = authenticationValidatedContext.AuthenticationTicket; @@ -573,7 +573,7 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m } else if (authorizationCodeReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeReceivedContext.ProtocolMessage; ticket = authorizationCodeReceivedContext.AuthenticationTicket; @@ -671,7 +671,7 @@ protected virtual async Task GetUserInformationAsync(OpenI } 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 312c8c281..0552ed2d7 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -44,7 +44,7 @@ protected override async Task HandleRemoteAuthenticateAsync( if (requestToken == null) { - return AuthenticateResult.Failed("Invalid state cookie."); + return AuthenticateResult.Fail("Invalid state cookie."); } properties = requestToken.Properties; @@ -54,18 +54,18 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 4f733fe7f..25d87a463 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 @@ public bool Succeeded 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 @@ public static AuthenticateResult Success(AuthenticationTicket ticket) return new AuthenticateResult() { Ticket = ticket }; } - public static AuthenticateResult Failed(Exception error) + public static AuthenticateResult Skip() + { + return new AuthenticateResult() { Skipped = true }; + } + + public static AuthenticateResult Fail(Exception failure) { - return new AuthenticateResult() { Error = error }; + return new AuthenticateResult() { Failure = failure }; } - public static AuthenticateResult Failed(string errorMessage) + public static AuthenticateResult Fail(string failureMessage) { - return new AuthenticateResult() { Error = new Exception(errorMessage) }; + return new AuthenticateResult() { Failure = new Exception(failureMessage) }; } } diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index 6dd298fbc..9beeb2482 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -100,6 +100,10 @@ public async Task InitializeAsync(TOptions options, HttpContext context, ILogger 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 @@ public async Task AuthenticateAsync(AuthenticateContext context) // 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 a8ef4b594..e0475d736 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 e19fd10b2..666783fd9 100644 --- a/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs @@ -10,7 +10,7 @@ public interface IRemoteAuthenticationEvents /// /// 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 fce53b992..d1c90be2f 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 8c58d072d..dda906369 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs @@ -22,11 +22,15 @@ public override async Task HandleRequestAsync() 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 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 2e3336e05..77fc76284 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -261,9 +261,9 @@ public async Task ReplyPathWithErrorFails(bool redirect) { 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 @@ public async Task ReplyPathWithErrorFails(bool redirect) { 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) { 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) { 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) { 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) { 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 @@ public async Task CanRedirectOnError() 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 @@ public async Task CanRedirectOnError() "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 aaef7ffa9..6100957ca 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -11,6 +11,7 @@ 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 @@ public async Task BearerDoesNothingTo401IfNotAuthenticated() 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 @@ private static TestServer CreateServer(Action configureOptions 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 @@ private static TestServer CreateServer(Action configureOptions 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 066/611] Updating to release NuGet.config. --- NuGet.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 5500f6d50..71b9724a0 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 067/611] #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 c79cbda95..33e807695 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -4,6 +4,7 @@ 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 @@ public void Configure(IApplicationBuilder app) 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 2e9dca157..cc2350bb9 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 73fe2b8b4..3e39d3654 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -4,6 +4,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 918dbcf3f..21f063382 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 01d26fcdf..5ca189aa9 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -14,6 +14,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) }); + // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) }; }); + // 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 @@ dnx . web { 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 000000000..13d3ff94a --- /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 823ac24c0..14c7606f1 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 068/611] 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 | 129 +++---- .../JwtBearer/JwtBearerMiddlewareTests.cs | 105 +++--- .../MicrosoftAccountMiddlewareTests.cs | 87 ++--- .../OpenIdConnectHandlerTests.cs | 13 +- .../OpenIdConnectMiddlewareTests.cs | 107 +++--- .../Twitter/TwitterMiddlewareTests.cs | 69 ++-- .../CookiePolicyTests.cs | 35 +- .../TicketInteropTests.cs | 33 +- 29 files changed, 585 insertions(+), 474 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 907710368..c85de8d26 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 2d77ae1bb..dca910512 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -2,6 +2,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 000000000..f8ef14574 --- /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 030c14983..20c5e0249 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 f4fbdd3fd..8d4a0316a 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 5affb5afa..bf7200ca6 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -3,6 +3,7 @@ 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 @@ await context.Authentication.SignInAsync(CookieAuthenticationDefaults.Authentica 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 000000000..f8ef14574 --- /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 a1c5ad3c6..cddabac49 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 33e807695..88032b8e6 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -112,6 +112,14 @@ public void Configure(IApplicationBuilder app) } // 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 000000000..f8ef14574 --- /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 cc2350bb9..bfb35107e 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 3d9d32eeb..c75dba9f4 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 3e39d3654..67a979ea9 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -2,6 +2,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 000000000..f8ef14574 --- /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 21f063382..9a204e142 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 dcfe9f514..b10006b86 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 5ca189aa9..59c57862a 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -12,6 +12,7 @@ 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 @@ dnx . web 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 @@ dnx . web 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 000000000..f8ef14574 --- /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 14c7606f1..53ade790c 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 8af2b8878..db27680d4 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.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 @@ public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthentica [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 @@ public async Task MapWillNotAffectChallenge() [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 @@ public async Task ChallengeDoesNotSet401OnUnauthorized() [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 @@ public async Task UseCookieWithInstanceDoesntUseSharedOptions() [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 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() [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 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() [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 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() [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 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() [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 @@ public async Task MapWillNotAffectAccessDenied() [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 @@ public async Task NestedMapWillNotAffectLogin() [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 @@ public async Task CanSpecifyAndShareDataProtector() { 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 => - { - options.AuthenticationScheme = "Cookies"; - options.CookieName = "Cookie"; - options.TicketDataFormat = new TicketDataFormat(dp); - }); - app.Use(async (context, next) => + var builder2 = new WebApplicationBuilder() + .Configure(app => { - 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 @@ private static async Task GetAuthData(TestServer server, string url, s 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" }); - - if (claimsTransform != null) + var builder = new WebApplicationBuilder() + .Configure(app => { - app.UseClaimsTransformation(claimsTransform); - } - app.Use(async (context, next) => - { - 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) + app.UseCookieAuthentication(configureOptions); + // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); + + if (claimsTransform != null) { - await testpath(context); + app.UseClaimsTransformation(claimsTransform); } - else + app.Use(async (context, next) => { - 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 c1796c3de..5263dadb5 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.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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 77fc76284..11fbe67e5 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -12,6 +12,7 @@ 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 @@ private static HttpResponseMessage ReturnJsonResponse(object content, HttpStatus private static TestServer CreateServer(Action configureOptions, Func testpath = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => - { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; - }); - app.UseGoogleAuthentication(configureOptions); - app.UseClaimsTransformation(p => + var builder = new WebApplicationBuilder() + .Configure(app => { - 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")) + app.UseCookieAuthentication(options => { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Google")); - } - else if (testpath != null) + options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; + options.AutomaticAuthenticate = true; + }); + app.UseGoogleAuthentication(configureOptions); + app.UseClaimsTransformation(p => { - await testpath(context); - } - else + var id = new ClaimsIdentity("xform"); + id.AddClaim(new Claim("xform", "yup")); + p.AddIdentity(id); + return Task.FromResult(p); + }); + app.Use(async (context, next) => { - await 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 => + { + services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme); }); - }, - 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 6100957ca..6bea890b1 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.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 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame private static TestServer CreateServer(Action configureOptions, Func handler = null) { - return TestServer.Create(app => - { - if (configureOptions != null) - { - app.UseJwtBearerAuthentication(configureOptions); - } - - app.Use(async (context, next) => + var builder = new WebApplicationBuilder() + .Configure(app => { - 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")) + + app.Use(async (context, next) => { - if (context.User == null || - context.User.Identity == null || - !context.User.Identity.IsAuthenticated) + if (context.Request.Path == new PathString("/checkforerrors")) { - context.Response.StatusCode = 401; - + 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; + } - 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()); + var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier); + if (identifier == null) + { + context.Response.StatusCode = 500; + + return; + } + + 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(); + } + }); + }) + .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 650c86465..1b5bd483b 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.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 @@ public async Task AuthenticatedEventCanGetRefreshToken() private static TestServer CreateServer(Action configureOptions) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => - { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; - }); - app.UseMicrosoftAccountAuthentication(configureOptions); - - app.Use(async (context, next) => + var builder = new WebApplicationBuilder() + .Configure(app => { - 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")) + app.UseCookieAuthentication(options => { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Microsoft")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Microsoft")); - } - else + options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; + options.AutomaticAuthenticate = true; + }); + app.UseMicrosoftAccountAuthentication(configureOptions); + + app.Use(async (context, next) => { - await next(); - } - }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => + 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 => { - options.SignInScheme = TestExtensions.CookieAuthenticationScheme; + 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 3c48657d1..99b7040ea 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.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 @@ private static void SetStateOptions(OpenIdConnectOptions options) 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 @@ private static TestServer CreateServer(Action configureOpt { 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 b9f0f26f8..9446be945 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -14,6 +14,7 @@ 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite private static TestServer CreateServer(Action configureOptions, Func handler = null, AuthenticationProperties properties = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => - { - options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - app.UseOpenIdConnectAuthentication(configureOptions); - app.Use(async (context, next) => + var builder = new WebApplicationBuilder() + .Configure(app => { - 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)) + app.UseCookieAuthentication(options => { - // 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) + options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + app.UseOpenIdConnectAuthentication(configureOptions); + app.Use(async (context, next) => { - await handler(context); - } - else - { - await next(); - } - }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => + 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 => { - 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 668f87481..db77d7f5f 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 @@ public async Task ChallengeWillTriggerRedirection() private static TestServer CreateServer(Action configure, Func handler = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => - { - options.AuthenticationScheme = "External"; - }); - app.UseTwitterAuthentication(configure); - app.Use(async (context, next) => + var builder = new WebApplicationBuilder() + .Configure(app => { - 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")) + app.UseCookieAuthentication(options => { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Twitter")); - } - else if (handler == null || !handler(context)) + options.AuthenticationScheme = "External"; + }); + app.UseTwitterAuthentication(configure); + app.Use(async (context, next) => { - await next(); - } - }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => + 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 => { - options.SignInScheme = "External"; + 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 78f20c9cf..4b798c561 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 @@ await RunTest("/httpOnlyNone", [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 @@ public async Task CookiePolicyCanHijackAppend() [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 @@ public async Task CookiePolicyCanHijackDelete() return Task.FromResult(0); }); }); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -177,7 +182,8 @@ public async Task CookiePolicyCanHijackDelete() [Fact] public async Task CookiePolicyCallsCookieFeature() { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.Use(next => context => { @@ -194,6 +200,7 @@ public async Task CookiePolicyCallsCookieFeature() 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 @@ private async Task RunTest( RequestDelegate configureSetup, params RequestTest[] tests) { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.Map(path, map => { @@ -259,6 +267,7 @@ private async Task RunTest( 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 725c5b1f2..71acba597 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.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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 069/611] 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 645cf2cde..698304132 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.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 1ab2a8b13..ad2160c06 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 124d8f543..9f8e4f957 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.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 dc2cce996..06b7442de 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 6bea890b1..7dee0f0ff 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.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 99b7040ea..801cc71f9 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.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 070/611] 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 88d41c663..830b559c9 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -6,7 +6,7 @@ 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 378916381..441145681 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs @@ -8,7 +8,7 @@ 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 152cc6290..55d2b0ed1 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs @@ -8,7 +8,7 @@ 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 590e0d778..c398b9279 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -7,7 +7,7 @@ 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 10b7bdf42..ea145fa6d 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs @@ -9,7 +9,7 @@ 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 52023d99d..a6f997170 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -9,7 +9,7 @@ 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 3c214b0d7..e1a1c1721 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs @@ -9,7 +9,7 @@ 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 c4b246641..ef36e17f0 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 40e16107c..2c1fcd20d 100644 --- a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs @@ -7,7 +7,7 @@ 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 0cd2647ce..14245e4d2 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 17b27128a..2a91eecdb 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.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 071/611] Stardardizing middleware to use ConfigureOption lambda --- samples/SocialSample/Startup.cs | 97 ++++++++++--------- .../CookieAppBuilderExtensions.cs | 29 +----- .../FacebookAppBuilderExtensions.cs | 33 ++----- .../GoogleAppBuilderExtensions.cs | 33 ++----- .../JwtBearerAppBuilderExtensions.cs | 39 ++------ .../MicrosoftAccountAppBuilderExtensions.cs | 33 ++----- .../OAuthAppBuilderExtensions.cs | 26 +---- .../OAuthOptions.cs | 3 - .../OpenIdConnectAppBuilderExtensions.cs | 30 +----- .../TwitterAppBuilderExtensions.cs | 27 +----- ...laimsTransformationAppBuilderExtensions.cs | 43 ++++---- .../CookiePolicyAppBuilderExtensions.cs | 26 +++-- .../Cookies/CookieMiddlewareTests.cs | 2 +- 13 files changed, 128 insertions(+), 293 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 59c57862a..f1bc5b335 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -72,26 +72,29 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) // 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 @@ Then you can choose to run the app as admin (see below) or add the following ACL 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 @@ dnx . web // 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 @@ dnx . web response.EnsureSuccessStatusCode(); var user = JObject.Parse(await response.Content.ReadAsStringAsync()); - + var identifier = user.Value("id"); if (!string.IsNullOrEmpty(identifier)) { @@ -243,7 +246,7 @@ dnx . web 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 0a8cd12ce..46539f875 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -23,7 +23,7 @@ public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuild throw new ArgumentNullException(nameof(app)); } - return app.UseCookieAuthentication(new CookieAuthenticationOptions()); + return app.UseCookieAuthentication(options => { }); } /// @@ -38,32 +38,13 @@ public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuild { throw new ArgumentNullException(nameof(app)); } - - var options = new CookieAuthenticationOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - 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)); - } + var options = new CookieAuthenticationOptions(); + 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 0889ec6ec..cc9b73f48 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 @@ public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBui { throw new ArgumentNullException(nameof(app)); } - - var options = new FacebookOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - return app.UseFacebookAuthentication(options); + + var options = new FacebookOptions(); + 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 67993bbc2..88e56928f 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 @@ public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuild { throw new ArgumentNullException(nameof(app)); } - - var options = new GoogleOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - return app.UseGoogleAuthentication(options); + + var options = new GoogleOptions(); + 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 80494f09d..0a1d01e44 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 @@ public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBu { throw new ArgumentNullException(nameof(app)); } - - var options = new JwtBearerOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - return app.UseJwtBearerAuthentication(options); + + var options = new JwtBearerOptions(); + 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 37a8d4180..34b2ae070 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 @@ public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplic { throw new ArgumentNullException(nameof(app)); } - - var options = new MicrosoftAccountOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - return app.UseMicrosoftAccountAuthentication(options); + + var options = new MicrosoftAccountOptions(); + 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 18aa62362..93db92cab 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -23,37 +23,13 @@ public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilde { 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 ba689e66b..a79c54672 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 f9b064137..5f2251226 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -15,7 +15,7 @@ public static class OpenIdConnectAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicati { throw new ArgumentNullException(nameof(app)); } - - - 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) + if (configureOptions == null) { - throw new ArgumentNullException(nameof(app)); + throw new ArgumentNullException(nameof(configureOptions)); } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } + var options = new OpenIdConnectOptions(); + 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 efff5937a..024d04e69 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -23,32 +23,13 @@ public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuil { throw new ArgumentNullException(nameof(app)); } - - var options = new TwitterOptions(); - if (configureOptions != null) + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - 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)); - } + var options = new TwitterOptions(); + configureOptions(options); return app.UseMiddleware(options); } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 4086c9591..702e65627 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 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild /// 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) + { + throw new ArgumentNullException(nameof(app)); + } + if (transform == null) + { + throw new ArgumentNullException(nameof(transform)); + } + + return app.UseClaimsTransformation(options => { - OnTransform = transform - }; - return app.UseClaimsTransformation(options); + options.Transformer = new ClaimsTransformer { OnTransform = transform }; + }); } /// @@ -48,12 +44,19 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild /// 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 f8a4af52f..c44a39360 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 @@ public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, /// 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) + { + throw new ArgumentNullException(nameof(app)); + } + if (configureOptions == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(configureOptions)); } - return app.UseCookiePolicy(options); + + 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 db27680d4..852b63f3e 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -793,7 +793,7 @@ public async Task UseCookieWithInstanceDoesntUseSharedOptions() .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 072/611] 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 46539f875..f990df58a 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -48,5 +48,25 @@ public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuild 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 cc9b73f48..f649790a1 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBui 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 88e56928f..34f65b112 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuild 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 0a1d01e44..da36d17f0 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -39,5 +39,31 @@ public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBu 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 34b2ae070..4066fa4ed 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplic 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 93db92cab..5599407ca 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilde 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 5f2251226..329820417 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicati 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 024d04e69..1701122b0 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -17,7 +17,7 @@ public static class TwitterAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuil 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 702e65627..21f80419f 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -58,5 +58,25 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild 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 c44a39360..95d52e55f 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -33,5 +33,25 @@ public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, 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 073/611] 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 096caeecd..1882efb51 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -88,6 +88,9 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera 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 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera { 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 03eccd2a6..487888d1f 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -67,5 +67,39 @@ public void CanReplaceDefaultPolicy() 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 074/611] 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 487888d1f..8807fa840 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -73,7 +73,7 @@ public void CombineMustTrimRoles() { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute("2") { Roles = "r1 , r2" } + new AuthorizeAttribute() { Roles = "r1 , r2" } }; var options = new AuthorizationOptions(); @@ -91,7 +91,7 @@ public void CombineMustTrimAuthenticationScheme() { // 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 075/611] 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 1882efb51..3e6d0a773 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -85,23 +85,27 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera 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 8807fa840..97430a121 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -77,8 +77,10 @@ public void CombineMustTrimRoles() }; 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 @@ public void CombineMustTrimAuthenticationScheme() }; 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 076/611] 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 3e6d0a773..befcb3c27 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -85,26 +85,22 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera 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 077/611] 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 9beeb2482..c45fdfa7e 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -108,7 +108,7 @@ public async Task InitializeAsync(TOptions options, HttpContext context, ILogger 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 078/611] 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 7dee0f0ff..33f573ca1 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 079/611] 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 968f1151b..63f116899 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -45,7 +45,7 @@ public async Task Authorize_ShouldAllowIfClaimIsPresent() 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 @@ public async Task Authorize_ShouldAllowIfClaimIsPresentWithSpecifiedAuthType() { 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 080/611] 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 84e0160fe..bdfe8b1c1 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs @@ -35,7 +35,6 @@ protected virtual Task HandleAsync(AuthorizationContext context, TRequirement re } public abstract class AuthorizationHandler : IAuthorizationHandler - where TResource : class where TRequirement : IAuthorizationRequirement { public virtual async Task HandleAsync(AuthorizationContext context) @@ -57,13 +56,11 @@ protected virtual Task HandleAsync(AuthorizationContext context, TRequirement re 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 63f116899..f2b28f6ab 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -817,6 +817,39 @@ protected override void Handle(AuthorizationContext context, OperationAuthorizat } } + 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 081/611] 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 e65640fea..7cef59614 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -186,7 +186,7 @@ protected override async Task FinishResponseAsync() cookieValue, cookieOptions); - await ApplyHeaders(shouldRedirectToReturnUrl: false); + await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: ticket.Properties); } } @@ -261,7 +261,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) // 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signOutContext) var context = new CookieSigningOutContext( Context, Options, + new AuthenticationProperties(signOutContext.Properties), cookieOptions); await Options.Events.SigningOut(context); @@ -288,10 +289,10 @@ protected override async Task HandleSignOutAsync(SignOutContext signOutContext) // 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 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl) 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 @@ private static bool IsHostRelative(string path) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 07a69dc35..437e8927e 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 @@ public class CookieRedirectContext : BaseCookieContext /// 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 @@ public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions op /// [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 838f73e62..17f5090cd 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -36,16 +36,16 @@ public CookieSignedInContext( /// /// 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 cf630fc31..fa441b4b0 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -39,7 +39,7 @@ public CookieSigningInContext( /// /// 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 55a9c762d..a510dbcb5 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 @@ public class CookieSigningOutContext : BaseCookieContext /// /// /// - 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 d39038471..8d9548c42 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -37,12 +37,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 1d692b454..f1a1eb145 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs @@ -31,12 +31,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 7a6ce6991..ae6b9d4c6 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 698304132..74faa2e63 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -203,7 +203,7 @@ protected override async Task HandleAuthenticateAsync() 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 940b11544..6c775906d 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -27,13 +27,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 05961d5ee..bae81bf8e 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -19,28 +19,36 @@ public class OAuthCreatingTicketContext : BaseContext /// /// 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 @@ public OAuthCreatingTicketContext( 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 1d36e1437..c7a3c5efa 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -155,11 +155,7 @@ private static async Task Display(HttpResponseMessage response) 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 b12aedce2..f9998b83e 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 9489e5c25..59f4d4911 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 @@ public class AuthorizationCodeReceivedContext : BaseOpenIdConnectContext /// /// 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 e433d2874..8e8b86a13 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 dcd06843c..fa1ef30d0 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 19c58dca9..e9522f70d 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 @@ public class TokenResponseReceivedContext : BaseOpenIdConnectContext /// /// 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 9f8e4f957..14472b4b9 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -99,7 +99,7 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con GenerateCorrelationId(properties); - var redirectContext = new RedirectContext(Context, Options) + var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message }; @@ -379,10 +379,9 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunTokenResponseReceivedEventAs 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 852b63f3e..329b0d176 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -533,6 +533,54 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() 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 082/611] 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 8d9548c42..44bc1468e 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 f1a1eb145..e4b50132a 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs @@ -32,7 +32,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 74faa2e63..08640019c 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -36,7 +36,7 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 6c775906d..35dcc9223 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,7 +28,8 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override async Task CreateTicketAsync(ClaimsIden } 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 bae81bf8e..835bb2e3a 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -19,36 +19,32 @@ public class OAuthCreatingTicketContext : BaseContext /// /// 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 @@ public OAuthCreatingTicketContext( Backchannel = backchannel; User = user; Options = options; - Principal = principal; - Properties = properties; + Ticket = ticket; } public OAuthOptions Options { get; } @@ -140,19 +135,14 @@ public TimeSpan? ExpiresIn 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 c7a3c5efa..6f197d86b 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -155,16 +155,10 @@ private static async Task Display(HttpResponseMessage response) 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 14472b4b9..2d157e48c 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -332,7 +332,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m 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 @@ protected virtual async Task GetUserInformationAsync(OpenI 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 @@ private async Task RunAuthorizationCodeReceive Code = message.Code, ProtocolMessage = message, RedirectUri = redirectUri, - AuthenticationTicket = ticket, + Ticket = ticket, JwtSecurityToken = jwt }; @@ -996,7 +996,7 @@ private async Task RunAuthenticationValidatedEve { var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options, properties) { - AuthenticationTicket = ticket, + Ticket = ticket, ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse, }; @@ -1020,7 +1020,7 @@ private async Task RunUserInformationReceivedEve 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 5e28dfc6c..4e986c808 100644 --- a/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs @@ -26,7 +26,7 @@ public bool 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. + /// Set the to trigger SignIn. /// public void HandleResponse() { @@ -43,8 +43,8 @@ public void SkipToNextMiddleware() } /// - /// 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 b2c5adbc5..28f6649fe 100644 --- a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs @@ -16,7 +16,7 @@ public TicketReceivedContext(HttpContext context, RemoteAuthenticationOptions op : 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 11fbe67e5..dcfe91e5a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -531,7 +531,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() { 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 33f573ca1..a3e7fbd54 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -82,7 +82,7 @@ public async Task CustomHeaderReceived() 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 @@ public async Task CustomTokenReceived() 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 @@ public async Task CustomTokenValidated() { // 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 @@ public async Task RetrievingTokenFromAlternateLocation() 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 @@ public async Task BearerTurns401To403IfAuthenticated() 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 @@ public async Task BearerDoesNothingTo401IfNotAuthenticated() 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 1b5bd483b..849cdfe0a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -150,7 +150,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 083/611] 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 7cef59614..82a47ecae 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -21,9 +21,9 @@ internal class CookieAuthenticationHandler : AuthenticationHandler _readCookieTask; @@ -37,6 +37,33 @@ private Task EnsureCookieTicket() 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 @@ private async Task ReadCookieTicket() 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 @@ protected override async Task HandleAuthenticateAsync() if (context.ShouldRenew) { - _shouldRenew = true; + RequestRefresh(result.Ticket); } return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Options.AuthenticationScheme)); @@ -144,7 +158,7 @@ private CookieOptions BuildCookieOptions() 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 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task FinishResponseAsync() 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 329b0d176..ffcf6d879 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -580,6 +580,61 @@ public async Task CookieValidatorOnlyCalledOnce() 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 084/611] Replace Microsoft.Owin.Security.Cookies.Interop by Microsoft.Owin.Security.Interop --- Security.sln | 58 ++++----- .../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, 231 insertions(+), 211 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} (88%) 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 77ed55284..28ecb032e 100644 --- a/Security.sln +++ b/Security.sln @@ -50,11 +50,11 @@ 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}" +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.Cookies.Interop.Test", "test\Microsoft.Owin.Security.Cookies.Interop.Test\Microsoft.Owin.Security.Cookies.Interop.Test.xproj", "{73E8E654-A2AC-4848-95F3-EB55512F6C39}" +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}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.xproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" +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 @@ -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 a252b138c..63f97cc9e 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 8fae5f923..36b269592 100644 --- a/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs +++ b/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs @@ -8,7 +8,7 @@ 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 3bbe74aad..000000000 --- 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 b403033e3..000000000 --- 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 b2437d9ad..000000000 --- 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 30053b01e..000000000 --- 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 48ded3309..f1a07c5bf 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.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 8727f7c46..2bfc44fde 100644 --- a/src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketSerializer.cs +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -7,7 +7,7 @@ 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 @@ public class AspNetTicketSerializer : IDataSerializer 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 0dab249ae..9dc7eedda 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 fd666b061..bb58ad712 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 000000000..4f0007e9c --- /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 000000000..b3c352a87 --- /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 71acba597..9ef81bc7f 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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() }); }) .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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ private class Transaction } } - 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 88% 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 3341cf4e6..c3f5e576d 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 000000000..10b3c4ae5 --- /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 000000000..781080552 --- /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 c206ad20e..585c87aa1 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 085/611] 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 10b3c4ae5..0675f8c9a 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; -using System.Runtime.InteropServices; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// 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("")] +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; -// 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 086/611] 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 4f0007e9c..c0526726a 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; -using System.Runtime.InteropServices; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// 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("")] +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; -// 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 0675f8c9a..000000000 --- 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 087/611] 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 | 33 +- .../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, 831 insertions(+), 833 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index dca910512..b3327ac81 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -20,9 +20,9 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 bf7200ca6..6160f56b9 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -21,10 +21,10 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 88032b8e6..db91629bc 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -59,13 +59,13 @@ public void Configure(IApplicationBuilder app) 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 67a979ea9..bf4a4bc75 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -35,18 +35,18 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 f1bc5b335..65067ada8 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -63,47 +63,44 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ Then you can choose to run the app as admin (see below) or add the following ACL 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 @@ dnx . web 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 f990df58a..858264887 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 @@ public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuild { 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 @@ public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuild 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 82a47ecae..040539d4d 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,6 +6,7 @@ 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 9ec406484..c15b10d34 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 @@ public CookieAuthenticationMiddleware( 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 830b559c9..075353887 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 6a437551f..d3e9127ee 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 437e8927e..4f0266b85 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 17f5090cd..2412722c0 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 fa441b4b0..709549d0a 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 a510dbcb5..2de962ef4 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 af0653385..435499bf5 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 b9b1d5d30..8a6fdac7b 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 f649790a1..19ff8fa67 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 @@ public static class FacebookAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBui 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 44bc1468e..7c74b253f 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -8,6 +8,7 @@ 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 441145681..f6d04171a 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs @@ -5,6 +5,7 @@ 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 @@ public FacebookMiddleware( 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 b6ceb5f0f..25e02cf77 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 34f65b112..e380ebf47 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 @@ public static class GoogleAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuild 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 e4b50132a..675e42442 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.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 55d2b0ed1..72ec3dee9 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs @@ -5,6 +5,7 @@ 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 @@ public GoogleMiddleware( 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 2c00278c7..eb1f0c3f1 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 f8848d210..02898af9c 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 91dd8cea2..50ed9ffc5 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 ae6b9d4c6..403e8ab7f 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 0aadaf2a9..a0c7a98c2 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 b0d824f3f..16ee6c1ce 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 9ae2fa68a..1f6e24e92 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 da36d17f0..bea74d741 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 @@ public static class JwtBearerAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBu 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 08640019c..be6e83c03 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -6,6 +6,7 @@ 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 ad518b966..7102cb61a 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 @@ public JwtBearerMiddleware( 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 ad2160c06..b028d0b5e 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs @@ -6,11 +6,13 @@ 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 4066fa4ed..1986227da 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 @@ public static class MicrosoftAccountAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplic 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 35dcc9223..f28c7ffc7 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -6,6 +6,7 @@ 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 c398b9279..5f0e36bb4 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 @@ public MicrosoftAccountMiddleware( 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 3339cf4cc..392df69bf 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 835bb2e3a..c2b35349e 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.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 7cc85f11a..8e3599605 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 5599407ca..8d71400ba 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 @@ public static class OAuthAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilde 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 6f197d86b..632932a3f 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -9,6 +9,7 @@ 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 ea145fa6d..72d34cbf7 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs @@ -6,6 +6,7 @@ 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 @@ public OAuthMiddleware( 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 a79c54672..d53e0a8bc 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 6c8edb9f4..a120c2402 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 f9998b83e..2469ef5c8 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 59f4d4911..f43be8198 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 8e8b86a13..e0c74c8db 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 76d63e27b..e207c836a 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 6439257cb..cb42c0f9b 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 fa1ef30d0..a87c3398e 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 e9522f70d..0e12bc291 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 fa0bc9277..80935354a 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 329820417..63cfe5009 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 @@ public static class OpenIdConnectAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicati 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 2d157e48c..12d61e334 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,6 +13,7 @@ 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 a6f997170..5dcd74d3c 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -6,6 +6,7 @@ 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 @@ public OpenIdConnectMiddleware( 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 06b7442de..af7a621de 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -5,13 +5,15 @@ 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 5a2f33758..d928fdcc7 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 d727eeb15..d5537ef95 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 455f52202..5569e8273 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 1701122b0..630370752 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 @@ public static class TwitterAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuil 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 0552ed2d7..3de3b37fd 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -9,6 +9,7 @@ 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 e1a1c1721..6b708a3a7 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs @@ -6,6 +6,7 @@ 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 @@ public TwitterMiddleware( 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 85e266326..19a3ca78a 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 c45fdfa7e..f68bddaf8 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 ef7cb5056..08e325bc0 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 @@ protected AuthenticationMiddleware( 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 758364244..5f8e56293 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 21f80419f..7dfa48217 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -5,6 +5,7 @@ using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Authentication; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -17,48 +18,40 @@ public static class ClaimsTransformationAppBuilderExtensions /// 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) + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - return app.UseClaimsTransformation(options => - { - options.Transformer = new ClaimsTransformer { OnTransform = transform }; - }); + return app.UseMiddleware(); } /// /// 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 function that asynchronously transforms one to another. /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Func> transform) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) + if (transform == null) { - throw new ArgumentNullException(nameof(configureOptions)); + throw new ArgumentNullException(nameof(transform)); } - var options = new ClaimsTransformationOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseClaimsTransformation(new ClaimsTransformationOptions + { + Transformer = new ClaimsTransformer { OnTransform = transform } + }); } - + /// /// Adds the middleware to the specified , which enables claims transformation capabilities. /// @@ -76,7 +69,7 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild 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 c84777cd8..f490af4a4 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 @@ public class ClaimsTransformationMiddleware public ClaimsTransformationMiddleware( RequestDelegate next, - ClaimsTransformationOptions options) + IOptions options) { if (next == null) { @@ -25,7 +27,7 @@ public ClaimsTransformationMiddleware( 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 19475ba02..e1ca6b900 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 28f6649fe..0663248cf 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 dda906369..cc1487d55 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 5fb3b4caf..afaee6c7b 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 dff8bf6fc..599a8fb27 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -24,8 +24,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic { 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 95d52e55f..02cbd22f9 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 @@ public static class CookiePolicyAppBuilderExtensions /// 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 @@ public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, 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 5c49b9e18..2fb299d16 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 @@ public class CookiePolicyMiddleware 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 ce5a86698..ffc2fa7b7 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 3eab1d58f..79ccda4a1 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 073d6f1e4..b5935938a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs @@ -6,6 +6,7 @@ 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 ffcf6d879..7827566a9 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -27,9 +27,7 @@ public class CookieMiddlewareTests [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 @@ public async Task NormalRequestPassesThrough() [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 @@ public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() [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 @@ public async Task AjaxForbidTurnsInto403WithLocationHeader() [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 @@ public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() [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 @@ public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() [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 @@ public async Task ProtectedRequestShouldRedirectToLoginOnlyWhenAutomatic(bool au [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 @@ private Task SignOutAsWrong(HttpContext context) [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 @@ public async Task SignInCausesDefaultCookieToBeCreated() [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 @@ public async Task SignInWrongAuthTypeThrows() [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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( 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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( [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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieContainsIdentity() 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 @@ public async Task CookieAppliesClaimsTransform() 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 @@ public async Task CookieStopsWorkingAfterExpiration() 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 @@ public async Task CookieExpirationCanBeOverridenInSignin() 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 @@ public async Task ExpiredCookieWithValidatorStillExpired() 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 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() ctx.HttpContext.Authentication.SignOutAsync("Cookies"); return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -444,19 +446,19 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() 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 @@ public async Task CookieCanBeRenewedByValidator() 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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -640,19 +642,19 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task CookieExpirationCanBeOverridenInEvent() 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 @@ public async Task CookieIsRenewedWithSlidingExpiration() 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 @@ public async Task CookieUsesPathBaseByDefault() 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 @@ public async Task CookieTurnsChallengeIntoForbidWithCookie(bool automatic) 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 @@ public async Task CookieChallengeRedirectsToLoginWithoutCookie(bool automatic) 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 @@ public async Task CookieForbidRedirectsWithoutCookie(bool automatic) 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 @@ public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() 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 @@ public async Task CookieChallengeRedirectsWithLoginPath() 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 @@ public async Task MapWillNotAffectChallenge() 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 @@ public async Task UseCookieWithInstanceDoesntUseSharedOptions() 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 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() 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 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() 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 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() 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 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() 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 @@ public async Task MapWillNotAffectAccessDenied() 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 @@ public async Task NestedMapWillNotAffectLogin() .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 @@ public async Task NestedMapWillNotAffectAccessDenied() .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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ private static async Task GetAuthData(TestServer server, string url, s 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 5263dadb5..95dcb2e5b 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -30,23 +30,23 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() 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 @@ public async Task NestedMapWillNotAffectRedirect() { 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 @@ public async Task MapWillNotAffectRedirect() 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 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() } return null; } - }; + } }); }, services => diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index dcfe91e5a..6a6f02828 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -28,10 +28,10 @@ public class GoogleMiddlewareTests [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 @@ public async Task ChallengeWillTriggerRedirection() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task ForbidThrows() [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 @@ public async Task Challenge401WillTriggerRedirection() [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 @@ public async Task ChallengeWillSetCorrelationCookie() [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 @@ public async Task Challenge401WillSetCorrelationCookie() [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 @@ public async Task ChallengeWillSetDefaultScope() [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 @@ public async Task Challenge401WillSetDefaultScope() [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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() [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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() [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 @@ public async Task AuthenticateWillFail() [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 @@ public async Task ReplyPathWithoutStateQueryStringWillBeRejected() [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 @@ public async Task ReplyPathWithErrorFails(bool redirect) 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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; + } }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -373,31 +370,28 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; - options.Events = new OAuthEvents + }, + Events = new OAuthEvents { OnCreatingTicket = context => { @@ -534,7 +525,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() 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 @@ public async Task ValidateAuthenticatedContext() 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 @@ public async Task ValidateAuthenticatedContext() throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; + } }); var properties = new AuthenticationProperties(); @@ -717,10 +708,10 @@ public async Task ValidateAuthenticatedContext() [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 @@ public async Task NoStateCausesException() 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 @@ public async Task CanRedirectOnError() ctx.HandleResponse(); return Task.FromResult(0); } - }; + } }); //Post a message to the Google middleware @@ -764,17 +755,17 @@ private static HttpResponseMessage ReturnJsonResponse(object content, HttpStatus 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 @@ private static TestServer CreateServer(Action configureOptions, F }) .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 a3e7fbd54..2732d0caa 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 @@ public class JwtBearerMiddlewareTests // 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 @@ public async Task BearerTokenValidation() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task CustomHeaderReceived() return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "someHeader someblob"); @@ -101,7 +101,7 @@ public async Task CustomHeaderReceived() [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 @@ public async Task NoHeaderReceived() [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 @@ public async Task HeaderWithoutBearerReceived() [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 @@ public async Task UnrecognizedTokenReceived() [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 @@ public async Task InvalidTokenReceived() [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 @@ public async Task CustomTokenReceived() return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); @@ -179,11 +179,10 @@ public async Task CustomTokenReceived() [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 @@ public async Task CustomTokenValidated() 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 @@ public async Task CustomTokenValidated() [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 @@ public async Task RetrievingTokenFromAlternateLocation() return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer Token"); @@ -255,9 +253,9 @@ public async Task RetrievingTokenFromAlternateLocation() [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 @@ public async Task BearerTurns401To403IfAuthenticated() return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -286,9 +284,9 @@ public async Task BearerTurns401To403IfAuthenticated() [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 @@ public async Task BearerDoesNothingTo401IfNotAuthenticated() return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/unauthorized"); @@ -317,11 +315,10 @@ public async Task BearerDoesNothingTo401IfNotAuthenticated() [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 @@ public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() { throw new NotImplementedException(); }, - }; + } }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -355,11 +352,10 @@ public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnReceivedTokenSkipped_NoMoreEventsExecuted() { throw new NotImplementedException(); }, - }; + } }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -389,12 +385,10 @@ public async Task EventOnReceivedTokenSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnValidatedTokenSkipped_NoMoreEventsExecuted() { 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 @@ public async Task EventOnValidatedTokenSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() { 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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() [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 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame } } - 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 849cdfe0a..29f6e0edc 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.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 @@ public class MicrosoftAccountMiddlewareTests [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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task ForbidThrows() [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 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() return null; } - }; - options.Events = new OAuthEvents + }, + Events = new OAuthEvents { OnCreatingTicket = context => { @@ -153,7 +149,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ private static TestServer CreateServer(Action configure .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 801cc71f9..0166c13e4 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.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 @@ public class OpenIdConnectHandlerTests 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 @@ public static TheoryData, OpenIdConnectMessage> Aut 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 @@ public static TheoryData, OpenIdConnectMessage> Aut 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 @@ private static void SetStateOptions(OpenIdConnectOptions options) 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 2a91eecdb..c73cf8f94 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 @@ public OpenIdConnectMiddlewareForTestingAuthenticate( 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 9446be945..992f7b9c9 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -42,12 +42,12 @@ public class OpenIdConnectMiddlewareTests [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 @@ public async Task ChallengeWillSetDefaults() 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 @@ public async Task ChallengeWillSetDefaults() [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 @@ public async Task ChallengeWillSetNonceAndStateCookies() 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 @@ public async Task ChallengeSettingMessage() { 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 @@ public async Task SignOutSettingMessage() { 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 @@ private static void SetProtocolMessageOptions(OpenIdConnectOptions options) return Task.FromResult(0); } }; + return options; } + private class FakeOpenIdConnectMessage : OpenIdConnectMessage { private readonly string _authorizeRequest; @@ -207,21 +204,19 @@ public async Task ChallengeSettingState(string userState, string challenge) 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 @@ public async Task ChallengeWillUseEvents() { 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 @@ private void SetOptions(OpenIdConnectOptions options, List parameters, E 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 @@ private static void DefaultChallengeOptions(OpenIdConnectOptions options) 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 @@ public async Task SignOutWithDefaultRedirectUri() 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 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 @@ await context.Authentication.SignOutAsync( .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 db77d7f5f..2d00d617d 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -20,19 +20,19 @@ public class TwitterMiddlewareTests [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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() } return null; } - }; + } }, context => { @@ -65,10 +65,10 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() [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 @@ public async Task BadSignInWillThrow() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task ForbidThrows() [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 @@ public async Task ChallengeWillTriggerRedirection() } return null; } - }; + } }, context => { @@ -150,16 +150,16 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ private static TestServer CreateServer(Action configure, Func { 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 f2b28f6ab..902bf17ce 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -19,6 +19,7 @@ private IAuthorizationService BuildAuthorizationService(Action options.Secure = SecurePolicy.Always, + new CookiePolicyOptions + { + Secure = SecurePolicy.Always + }, SecureCookieAppends, new RequestTest("http://example.com/secureAlways", transaction => @@ -53,7 +56,10 @@ await RunTest("/secureAlways", 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 @@ await RunTest("/secureNone", 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 @@ await RunTest("/secureSame", 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 @@ await RunTest("/httpOnlyAlways", 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 @@ public async Task CookiePolicyCanHijackAppend() 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 @@ public async Task CookiePolicyCanHijackDelete() 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 @@ public async Task CookiePolicyCallsCookieFeature() 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 @@ public async Task Execute(TestServer server) private async Task RunTest( string path, - Action configureCookiePolicy, + CookiePolicyOptions cookiePolicy, RequestDelegate configureSetup, params RequestTest[] tests) { @@ -263,7 +287,7 @@ private async Task RunTest( { 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 9ef81bc7f..c7645a287 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -38,7 +38,7 @@ public async Task AspNet5WithInteropCookieContainsIdentity() { 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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() { 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 088/611] 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 b3327ac81..64376e26e 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,6 +46,7 @@ public static void Main(string[] args) { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 6160f56b9..d9504d942 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,6 +56,7 @@ public static void Main(string[] args) { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index db91629bc..abfd83735 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -116,6 +116,7 @@ public static void Main(string[] args) { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bf4a4bc75..50452d173 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -69,6 +69,7 @@ public static void Main(string[] args) { 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 b10006b86..15c91efdc 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 65067ada8..e466c019d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -6,7 +6,6 @@ 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 @@ public static void Main(string[] args) { 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 089/611] 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 a0378f9c1..053ff4960 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs @@ -123,14 +123,19 @@ public AuthorizationPolicyBuilder RequireAuthenticatedUser() 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 000000000..b0eb44cf9 --- /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 834060bb6..000000000 --- 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 902bf17ce..fc4377aeb 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -905,13 +905,13 @@ public async Task AuthorizeHandlerNotCalledWithNullResource() } [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 090/611] Build with dotnet --- .gitattributes | 1 + .gitignore | 2 + .travis.yml | 8 ++- appveyor.yml | 2 +- build.cmd | 64 +++++++++---------- build.sh | 40 ++++++------ makefile.shade | 7 -- .../project.json | 23 +++++-- .../project.json | 22 +++++-- .../project.json | 25 ++++++-- .../project.json | 15 +++-- 11 files changed, 128 insertions(+), 81 deletions(-) delete mode 100644 makefile.shade diff --git a/.gitattributes b/.gitattributes index bdaa5ba98..97b827b75 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 ac82da756..a2eb01c89 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 c0befaffc..bf811dc26 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 636a7618d..3fab83e13 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 553e3929a..ebb619e73 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 + +IF NOT EXIST %BUILD_FOLDER% ( + md %BUILD_FOLDER% ) -.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 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 "%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 %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% ) -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* diff --git a/build.sh b/build.sh index da4e3fcd1..263fb667a 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 -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 + 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 + cp $cacheNuget $nugetPath fi -if ! type dnvm > /dev/null 2>&1; then - source packages/KoreBuild/build/dnvm.sh +if test ! -d $koreBuildFolder; then + mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre + chmod +x $koreBuildFolder/build/KoreBuild.sh 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 +makeFile=makefile.shade +if [ ! -e $makeFile ]; then + makeFile=$koreBuildFolder/build/makefile.shade 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 562494d14..000000000 --- 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 af0759d42..f9a5e1f3e 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-*" + "xunit": "2.1.0" }, + "frameworks": { + "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" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } } } diff --git a/test/Microsoft.AspNet.Authorization.Test/project.json b/test/Microsoft.AspNet.Authorization.Test/project.json index 7bbe7ed75..1fa1347e1 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 509e74916..66d7c743f 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-*" + "xunit": "2.1.0" }, + "frameworks": { + "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" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } } + } diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 585c87aa1..e4af613d9 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-*" + "xunit": "2.1.0", + "xunit.runner.console": "2.1.0" }, + "frameworks": { + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "" + } + } + }, + "testRunner": "xunit", "commands": { "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { } } } From 0f9875df0a43f1a84fbf113341cac636d547c283 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 17 Jan 2016 17:09:38 -0800 Subject: [PATCH 091/611] 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 a2eb01c89..0f91ad120 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 64376e26e..a1a5d5bbc 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -44,13 +44,13 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 d9504d942..6c6c6f360 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -54,13 +54,13 @@ await context.Authentication.SignInAsync(CookieAuthenticationDefaults.Authentica 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 abfd83735..4ef2f6610 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -114,13 +114,13 @@ public void Configure(IApplicationBuilder app) // 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 50452d173..1d40a0a92 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -67,13 +67,13 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 e466c019d..2641725df 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -325,13 +325,13 @@ dnx . web 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 7827566a9..e6fc0d709 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -854,7 +854,7 @@ public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthentica [Fact] public async Task MapWillNotAffectChallenge() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -878,7 +878,7 @@ public async Task MapWillNotAffectChallenge() [Fact] public async Task ChallengeDoesNotSet401OnUnauthorized() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(); @@ -897,7 +897,7 @@ public async Task ChallengeDoesNotSet401OnUnauthorized() [Fact] public async Task UseCookieWithInstanceDoesntUseSharedOptions() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -919,7 +919,7 @@ public async Task UseCookieWithInstanceDoesntUseSharedOptions() [Fact] public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -940,7 +940,7 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() [Fact] public async Task MapWillNotAffectSignInRedirectToReturnUrl() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -965,7 +965,7 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() [Fact] public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -985,7 +985,7 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() [Fact] public async Task MapWillNotAffectSignOutRedirectToReturnUrl() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1009,7 +1009,7 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() [Fact] public async Task MapWillNotAffectAccessDenied() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1031,7 +1031,7 @@ public async Task MapWillNotAffectAccessDenied() [Fact] public async Task NestedMapWillNotAffectLogin() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => app.Map("/base", map => { @@ -1055,7 +1055,7 @@ public async Task NestedMapWillNotAffectLogin() [Fact] public async Task NestedMapWillNotAffectAccessDenied() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => app.Map("/base", map => { @@ -1080,7 +1080,7 @@ public async Task CanSpecifyAndShareDataProtector() { var dp = new NoOpDataProtector(); - var builder1 = new WebApplicationBuilder() + var builder1 = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1099,7 +1099,7 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ private static async Task GetAuthData(TestServer server, string url, s 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 95dcb2e5b..764b63a15 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -229,7 +229,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 6a6f02828..29cc78403 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -757,7 +757,7 @@ private static HttpResponseMessage ReturnJsonResponse(object content, HttpStatus 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 2732d0caa..6ff7751a9 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -535,7 +535,7 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame 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 29f6e0edc..6d41f5a7a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -174,7 +174,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 0166c13e4..fa4905539 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs @@ -98,7 +98,7 @@ private static OpenIdConnectOptions GetStateOptions() 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 992f7b9c9..6661eeb54 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -377,7 +377,7 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 2d00d617d..173de5a82 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -152,7 +152,7 @@ public async Task ChallengeWillTriggerRedirection() 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 d0639e627..f8529e019 100644 --- a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs @@ -145,7 +145,7 @@ await RunTest("/httpOnlyNone", [Fact] public async Task CookiePolicyCanHijackAppend() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookiePolicy(new CookiePolicyOptions @@ -175,7 +175,7 @@ public async Task CookiePolicyCanHijackAppend() [Fact] public async Task CookiePolicyCanHijackDelete() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookiePolicy(new CookiePolicyOptions @@ -203,7 +203,7 @@ public async Task CookiePolicyCanHijackDelete() [Fact] public async Task CookiePolicyCallsCookieFeature() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.Use(next => context => @@ -282,7 +282,7 @@ private async Task RunTest( 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 c7645a287..996e18160 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -52,7 +52,7 @@ public async Task AspNet5WithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() "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 092/611] 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 1d40a0a92..7c469ef29 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -26,7 +26,8 @@ public Startup() 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 12d61e334..e9f4d3ae0 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -84,21 +84,29 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (message == null) { + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return AuthenticateResult.Skip(); + } return AuthenticateResult.Fail("No message."); } @@ -344,7 +362,11 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m { // 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m // 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 @@ protected virtual async Task GetUserInformationAsync(OpenI { 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 @@ protected virtual async Task GetUserInformationAsync(OpenI /// 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 af7a621de..cd31e27d0 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -48,19 +48,12 @@ public OpenIdConnectOptions() 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 afaee6c7b..939237939 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 @@ public string DisplayName /// /// 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 c0333cb2f..000000000 --- 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 fa4905539..000000000 --- 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 c73cf8f94..000000000 --- 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 b5371965c..e48aa6604 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs @@ -27,9 +27,9 @@ public static OpenIdConnectConfiguration DefaultOpenIdConnectConfiguration { 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 093/611] 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 094/611] 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 c3d5401e6..4c7cf6982 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 28ecb032e..4c24c1d22 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 a1a5d5bbc..1f8b494c4 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 f8ef14574..6a93dbafa 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 20c5e0249..22d51833b 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 833ad35ac..ebb660361 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 6c6c6f360..57593d878 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 f8ef14574..6a93dbafa 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 cddabac49..dd5826248 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 4ef2f6610..34ee646c7 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 f8ef14574..6a93dbafa 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 bfb35107e..9ba387d67 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 7c469ef29..11a95a571 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 f8ef14574..6a93dbafa 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 9a204e142..3b2caff5e 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 2641725df..e95994379 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -5,15 +5,15 @@ 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 f8ef14574..6a93dbafa 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 53ade790c..a8eb114c9 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 70d7096cb..380e6f937 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs @@ -6,11 +6,11 @@ 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 c9d6194ba..3aabf94c1 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 858264887..765d1f51c 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 715c25100..2baa9e45c 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 @@ public static class CookieAuthenticationDefaults /// /// 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 040539d4d..b056d0787 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,21 +6,21 @@ 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 c15b10d34..ff54957cf 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 075353887..dc1a63bbf 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 @@ public CookieAuthenticationOptions() } /// - /// 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 83d34d0ae..5a35415d1 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 d3e9127ee..e5423fed2 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 e78db2a87..ffe687e5f 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 4f0266b85..e946548f4 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 2412722c0..cfb7c5f1d 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 709549d0a..d8b2307f3 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 2de962ef4..ab5858e36 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 435499bf5..d2c1fd42f 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 9c3cc912d..1406d872d 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 0aa9855ee..4514fefa9 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 418dec45e..cff11a892 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 ede713df8..e2719f39d 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 8a6fdac7b..de5c6c09d 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 19ff8fa67..0435db794 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 d2896a5ce..da65e246b 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 7c74b253f..126f48d66 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -7,13 +7,13 @@ 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 bb950f32a..af68a7c32 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 f6d04171a..4ceda639c 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 25e02cf77..af82c6f9a 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 69c667575..a3a2f2874 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 0c64cafa9..2a11e8fd5 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 e380ebf47..fe693a61b 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 ebd05602a..06fd12eb1 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 675e42442..affde917a 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.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 5327ddcb2..0a763d569 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs @@ -5,7 +5,7 @@ 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 72ec3dee9..565d89b0c 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 eb1f0c3f1..208d71065 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 5003d937b..690c5a280 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 47736748c..10862c318 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 02898af9c..b3e0f0bdc 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 50ed9ffc5..5c28f2976 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 cf47ab47e..4ad6f7c21 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs @@ -6,7 +6,7 @@ /// /// 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 403e8ab7f..b3a4d21ba 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 7fcf922e5..5fc8a6b6c 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 a0c7a98c2..e38c49cf1 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 16ee6c1ce..e93ad824a 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 1f6e24e92..3a1dad812 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 bea74d741..13c06ca38 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 5b73bf156..649edf94b 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 be6e83c03..67889d51d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -6,16 +6,16 @@ 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 7102cb61a..bfb38793f 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 b028d0b5e..0a08ff3e4 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -6,13 +6,13 @@ 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 79bbbe449..ef1d784f2 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 16b169298..0ff272736 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 1986227da..660dd2e81 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 be0732ae6..d85379477 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 f28c7ffc7..245fbed87 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.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 b0573688e..8b88cbc44 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 5f0e36bb4..8daa9b2ad 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 392df69bf..7adfa5705 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 6a20332bd..618d143ee 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 b1528b935..db03dbd5c 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 53114e244..fb4d8b76d 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 4c800c984..76a238e07 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 c2b35349e..15f9c91c7 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.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 07de38640..cf1528e28 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 8e3599605..5dcbd568c 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 8d71400ba..eebeaf7a3 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 632932a3f..7f59443bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -9,16 +9,16 @@ 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 72d34cbf7..401537e83 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -6,13 +6,13 @@ 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 d53e0a8bc..230c7362a 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 7a45120b4..aa4026b00 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 d17513cba..00c7b848b 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 1d6833e3e..352ccfe90 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 a120c2402..776f78d6e 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 2469ef5c8..4e1979645 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 f43be8198..d1737cd25 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 e0c74c8db..7d17d3cf8 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 e207c836a..d2f56a4ce 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 b6bcfd57d..da956acf8 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 cb42c0f9b..d535f35f9 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 c84e5546a..249342eec 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 a87c3398e..59b1c0efd 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 0e12bc291..b4a9ad6d1 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 80935354a..c0a53db44 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 63cfe5009..07aefec42 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 e280a6afb..378c59447 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 @@ public static class OpenIdConnectDefaults /// /// 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 e9f4d3ae0..8ade6ee63 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,17 +13,17 @@ 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 5dcd74d3c..09901cf37 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -6,15 +6,15 @@ 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 cd31e27d0..4ae05a2bb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -5,15 +5,15 @@ 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 5c0176627..2f419df18 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 64b345f95..65a9273a0 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 58d9d5a40..04354e351 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 d928fdcc7..5f00cb18b 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 cea4a99bf..76b487b96 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 d5537ef95..97d1d176a 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 1941e7990..99122e855 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 5569e8273..aa1da43ed 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 880cf69d9..550163bec 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 94a766e02..04c334e3d 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 6d3adeb1c..a96a379c1 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 9a385b546..d60c2fc73 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 630370752..df6ca1d02 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 a546dba9c..0610ccfc9 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 3de3b37fd..a4a1a0802 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -9,16 +9,16 @@ 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 6b708a3a7..1a1e199cc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -6,13 +6,13 @@ 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 19a3ca78a..cd13d1798 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 6c4124a1b..67ebf2c0d 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 25d87a463..fb97931cb 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 f68bddaf8..ff98a1031 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 08e325bc0..ad63b1761 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 5f8e56293..8f1fb0691 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 72032f53b..9ce76d7e6 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 dffcebc08..1d56a8fb3 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 7dfa48217..1cc76b946 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 954f26032..78d9a0845 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 f490af4a4..2e2216bc2 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 e1ca6b900..7772457a0 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 e824689d1..b8e7ea3e1 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs @@ -5,7 +5,7 @@ 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 4fc7b49be..ad9c52300 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 c44729e12..73b1b882b 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 956794815..3d31e4bd2 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 e6d6bc1d8..542553cf2 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs @@ -5,9 +5,9 @@ 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 339d3ed22..f35025d8b 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 009413ed0..c07a314b0 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 63f97cc9e..e43943cfc 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 36b269592..e33ec7172 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs @@ -6,7 +6,7 @@ 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 0286871e9..10b3325d4 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 4e986c808..db81ad704 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 c3437ddff..80a6f949a 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 e0475d736..35af9cee3 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 666783fd9..e2109a065 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 d1c90be2f..ee45b8afd 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 0663248cf..5d5fd4883 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 0234f22cd..eea17bcc3 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 a4e4e2f25..03eece931 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 dedb6d36a..558266986 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 b1dc46b06..29dd7c67e 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 cc1487d55..ef4a1db52 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 939237939..86fcdcc97 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 5a03a279f..bf30cae9e 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 405b8afa2..0f9c2a30a 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 ef36e17f0..c7a58a242 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 b61a01446..cb3f1b172 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 93f4da651..455adb0dd 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs @@ -6,7 +6,7 @@ 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 bdfe8b1c1..2bd90aad4 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 66627b458..c3019c907 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 befcb3c27..97aa5b381 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -5,7 +5,7 @@ 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 053ff4960..0cc0195e6 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 599a8fb27..120dffda5 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 5ab5b03e7..a2b0a755c 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -6,7 +6,7 @@ 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 a20436ce9..cdfab44f1 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 2c1fcd20d..d501f1b20 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -9,7 +9,7 @@ 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 3ba290a98..7593e0ad3 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 84ebbc9a3..fc8ba6e7f 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 19857b618..800789a8c 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 a9dbe06cd..e3b9fec91 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -5,7 +5,7 @@ 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 a49b4892a..3371134b4 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 b0eb44cf9..0d3ab2bf2 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 82e3ac5b6..bff54954d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,7 +5,7 @@ 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 1011baef3..44ab475de 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 dc9ea9eda..a4f2455a6 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 0beaaa244..455d66ff2 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 1ea353f93..480e2de0c 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 21b3729de..217e3ea0c 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,7 +5,7 @@ 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 9242639ff..116001e65 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 14245e4d2..79691d0a4 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 f9d816661..1b13251f7 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 02cbd22f9..bb5700fc6 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 2fb299d16..d9a65028c 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 ffc2fa7b7..812c71428 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 c8cd208fb..f0693bf71 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 276e3ed3e..82305f475 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 7790eac27..4b5fbfe3b 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 962ecddff..c0dd639f1 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 79ccda4a1..a2c04f145 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 2bfc44fde..6a1019fbc 100644 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -9,7 +9,7 @@ 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 9dc7eedda..731358894 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 b3c352a87..953428b7b 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 b5935938a..431c35bdb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -6,16 +6,16 @@ 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 e6fc0d709..158c48051 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.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 84d496918..71590727c 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 8e6268430..3195298c0 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 2cfdd4e79..bda4b09fa 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 0ab8bce41..8eeedde0d 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.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 764b63a15..fa2bed53f 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.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 29cc78403..7daec9863 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.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 6ff7751a9..72d13a4c9 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.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 6d41f5a7a..f80ee2122 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.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 66cc84621..494e2d92a 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 d1f65aed2..66fc2f4ba 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs @@ -9,7 +9,7 @@ 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 6661eeb54..4c95083d5 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.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 e48aa6604..6247c85b4 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 20495125d..c34e4fd2d 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 8d3cdb7e2..2e9001dd8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs @@ -9,10 +9,10 @@ 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 1a93b16df..5289e3880 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs @@ -5,7 +5,7 @@ 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 e32c3b926..56058b850 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -6,7 +6,7 @@ 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 173de5a82..2ca2223b9 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.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 f9a5e1f3e..5f6dcb9ae 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 97430a121..f74e46152 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 fc4377aeb..89b7d779a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -6,11 +6,11 @@ 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 1fa1347e1..b271d43eb 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 f8529e019..fde603497 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 b0a49fddd..b04b3cd61 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 9cd07cb36..9456094d4 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs @@ -9,10 +9,10 @@ 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 afa9c0c99..25457e991 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs @@ -6,7 +6,7 @@ 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 66d7c743f..4ee196a26 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 996e18160..08df19011 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.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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 781080552..06073e8b7 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 e4af613d9..660f33868 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 095/611] 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 3b2caff5e..b0befb540 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 04354e351..40825201c 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 5f6dcb9ae..dcaa71f52 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 096/611] #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 7f59443bf..c31f6e29e 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 230c7362a..a094e681b 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 @@ public OAuthOptions() /// 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 8ade6ee63..379beba2d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -778,8 +778,15 @@ private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, 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 4ae05a2bb..9e8eef1e1 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 097/611] #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 a4a1a0802..3b66f3128 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -91,6 +91,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 098/611] 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 158c48051..785d5bfa6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -438,7 +438,7 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() 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 @@ public async Task UseCookieWithInstanceDoesntUseSharedOptions() 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 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() 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 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() 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 fa2bed53f..aadb62f51 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -212,7 +212,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() }, 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 7daec9863..854c49ce9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -111,7 +111,7 @@ public async Task ChallengeWillSetCorrelationCookie() 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 @@ public async Task Challenge401WillSetCorrelationCookie() 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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla } }); 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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) } : 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) } : 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() } }); 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() } }); 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 @@ public async Task NullRedirectUriWillRedirectToSlash() 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 @@ public async Task ValidateAuthenticatedContext() }); 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 f80ee2122..2aad3cfef 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -152,7 +152,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() } }); 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 4c95083d5..040812d88 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -486,7 +486,7 @@ public string AuthenticationCookieValue { 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 56058b850..63f8af1bb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -24,7 +24,7 @@ public string AuthenticationCookieValue { 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 25457e991..040e0b339 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs @@ -25,7 +25,7 @@ public string AuthenticationCookieValue { 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 08df19011..ef80b78e6 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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() 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 @@ public async Task AspNet5WithInteropCookieContainsIdentity() var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions { DataProtectionProvider = dataProtection }); @@ -66,7 +68,7 @@ public async Task AspNet5WithInteropCookieContainsIdentity() }); }) .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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 06073e8b7..7b2d261bb 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -58,14 +58,14 @@ public void InteropSerializerCanReadNewTicket() 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 099/611] 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 79691d0a4..688fd8403 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 100/611] 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 379beba2d..365010147 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -511,7 +511,7 @@ private async Task HandleCodeOnlyFlow(OpenIdConnectMessage m // 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 101/611] 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 120dffda5..d03f9ed74 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -26,6 +26,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic } 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 000000000..97b806e87 --- /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 d501f1b20..c5bdcc7a7 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -7,21 +7,20 @@ 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 @@ public DefaultAuthorizationService(IOptions options, IEnum } _handlers = handlers.ToArray(); - _options = options.Value; + _policyProvider = policyProvider; _logger = logger; } @@ -62,19 +61,19 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE } } - 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 000000000..1a0dbace6 --- /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 89b7d779a..60988448b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -922,5 +922,64 @@ public async Task CanAuthorizeWithAssertionRequirement() // 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 b271d43eb..a2b212276 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 102/611] 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 67889d51d..00ecae0fb 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -119,7 +119,7 @@ protected override async Task HandleAuthenticateAsync() } 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 @@ protected override async Task HandleAuthenticateAsync() } 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 103/611] #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 e95994379..8e6cd1768 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -133,18 +133,18 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 565d89b0c..f81497f26 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -67,16 +67,6 @@ public GoogleMiddleware( { 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 208d71065..3d93b96ea 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs @@ -22,6 +22,9 @@ public GoogleOptions() 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 8daa9b2ad..e7ba9f811 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -65,13 +65,6 @@ public MicrosoftAccountMiddleware( { 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 7adfa5705..2783bcef1 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,6 +22,7 @@ public MicrosoftAccountOptions() 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 104/611] 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 0cc0195e6..965ffe02e 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 @@ public AuthorizationPolicyBuilder RequireAssertion(Func + /// 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 0d3ab2bf2..0cc1751a4 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 @@ public AssertionRequirement(Func assert) 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 60988448b..7f1191694 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -923,6 +923,25 @@ public async Task CanAuthorizeWithAssertionRequirement() 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 105/611] 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 | 144 ++++++++++++++++-- .../FacebookMiddleware.cs | 1 + .../FacebookOptions.cs | 7 +- 4 files changed, 200 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 126f48d66..675ae5149 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -48,10 +48,22 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 af68a7c32..48e359099 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs @@ -26,16 +26,91 @@ public static string GetId(JObject user) } /// - /// 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"); + } - return user.Value("name"); + /// + /// 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"); } /// @@ -51,30 +126,81 @@ public static string GetLink(JObject user) } /// - /// Gets the Facebook username. + /// 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 GetUserName(JObject user) + public static string GetMiddleName(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("username"); + 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 Facebook email. + /// Gets the user's timezone. /// - public static string GetEmail(JObject user) + public static string GetTimeZone(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } + return user.Value("timezone"); + } - return user.Value("email"); + // 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 4ceda639c..16b60e1dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -71,6 +71,7 @@ public FacebookMiddleware( { 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 af82c6f9a..ac6987f3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -24,7 +24,10 @@ public FacebookOptions() 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 @@ public string AppSecret /// 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 106/611] 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 a094e681b..22d5e3557 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -56,9 +56,9 @@ public OAuthOptions() } /// - /// 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 9e8eef1e1..de7bee163 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -53,6 +53,8 @@ public OpenIdConnectOptions(string authenticationScheme) DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); Events = new OpenIdConnectEvents(); + Scope.Add("openid"); + Scope.Add("profile"); } /// @@ -155,7 +157,7 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 107/611] 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 1f8b494c4..8b0568b31 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,6 +46,7 @@ public static void Main(string[] args) { 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 6a93dbafa..000000000 --- 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 57593d878..3db8f1155 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,6 +56,7 @@ public static void Main(string[] args) { 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 6a93dbafa..000000000 --- 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 34ee646c7..3a4ecfba6 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -116,6 +116,7 @@ public static void Main(string[] args) { 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 6a93dbafa..000000000 --- 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 11a95a571..f0f9feb3a 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -70,6 +70,7 @@ public static void Main(string[] args) { 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 6a93dbafa..000000000 --- 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 8e6cd1768..ffbaf8dc5 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -327,6 +327,7 @@ public static void Main(string[] args) { 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 6a93dbafa..000000000 --- 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 108/611] 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 de5c6c09d..5ceb5b7a6 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 2a11e8fd5..479a08011 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 352ccfe90..504986210 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 109/611] 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 22d51833b..fa17dd9cf 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 dd5826248..8de831b40 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 9ba387d67..436a2203b 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 b0befb540..e5bec9e8c 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 a8eb114c9..00570902f 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 479a08011..5dbf6f6cf 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 10862c318..929424cc1 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 0ff272736..f6e200b7c 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 db03dbd5c..c415b2a63 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 504986210..c5128412c 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 40825201c..90487a898 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 c7a58a242..d34a6697b 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 dcaa71f52..2048801a6 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 a2b212276..d5d554462 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 4ee196a26..d39a05974 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 660f33868..46fd46b48 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 110/611] 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 fb4d8b76d..000000000 --- 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 c31f6e29e..7a06bee70 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -7,15 +7,12 @@ 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected virtual string FormatScope() // 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 378c59447..a099a7276 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -28,11 +28,6 @@ public static class OpenIdConnectDefaults /// 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 365010147..f7c675ff3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -184,7 +184,10 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con // 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 @@ private void WriteNonceCookie(string nonce) { HttpOnly = true, Secure = Request.IsHttps, - Expires = DateTime.UtcNow + Options.ProtocolValidator.NonceLifetime + Expires = Options.SystemClock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); } @@ -857,76 +860,6 @@ private string ReadNonceCookie(string nonce) 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 3b66f3128..c39cce121 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -122,7 +122,11 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 cd13d1798..77fb0bd7a 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 @@ public TwitterOptions() 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 ef4a1db52..bf64109a2 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 @@ protected override Task HandleForbiddenAsync(ChallengeContext context) { 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 86fcdcc97..0388c04bd 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -56,6 +56,11 @@ public string DisplayName /// 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 aadb62f51..eaa339d15 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -212,14 +212,14 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() }, 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 854c49ce9..6a0780812 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -111,7 +111,7 @@ public async Task ChallengeWillSetCorrelationCookie() 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 @@ public async Task Challenge401WillSetCorrelationCookie() 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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla } }); 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) } : 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) } : 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() } }); 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 @@ public async Task NullRedirectUriWillRedirectToSlash() } }); 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 @@ public async Task ValidateAuthenticatedContext() }); 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 @@ public async Task ValidateAuthenticatedContext() //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 2aad3cfef..f5a43b8ed 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -152,18 +152,18 @@ public async Task AuthenticatedEventCanGetRefreshToken() } }); 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 494e2d92a..1be4b80bc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs @@ -22,11 +22,10 @@ public string Protect(AuthenticationProperties data) 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 040812d88..cadcf8088 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -84,7 +84,7 @@ public async Task ChallengeWillSetNonceAndStateCookies() 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 111/611] #456 Unify OIDC Code/IdToken/Hybride flows. --- samples/OpenIdConnectSample/Startup.cs | 46 +- .../OpenIdConnectHandler.cs | 419 ++++++++---------- 2 files changed, 227 insertions(+), 238 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index f0f9feb3a..ddcf9fa2b 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 @@ 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 @@ -52,17 +75,30 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 = "/" }); - - context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync("Hello First timer"); return; } - context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync("Hello Authenticated User"); + 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 f7c675ff3..4084e2100 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -308,16 +308,16 @@ protected override async Task HandleRemoteAuthenticateAsync( { 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 @@ protected override async Task HandleRemoteAuthenticateAsync( && 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( _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) + return result; + } + authorizationResponse = authorizationResponseReceivedContext.ProtocolMessage; + properties = authorizationResponseReceivedContext.Properties; + + 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)) { - Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); - return AuthenticateResult.Success(authorizationResponseReceivedContext.Ticket); + 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 (authorizationResponseReceivedContext.Skipped) + + Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() { - Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); - return AuthenticateResult.Skip(); + 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)) + { + // 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 + }); } - message = authorizationResponseReceivedContext.ProtocolMessage; - properties = authorizationResponseReceivedContext.Properties; - if (string.IsNullOrEmpty(message.IdToken) && !string.IsNullOrEmpty(message.Code)) + var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(authorizationResponse, ticket, properties, tokenEndpointResponse); + if (CheckEventResult(authenticationValidatedContext, out result)) { - return await HandleCodeOnlyFlow(message, properties); + return result; } - else if (!string.IsNullOrEmpty(message.IdToken)) + authorizationResponse = authenticationValidatedContext.ProtocolMessage; + tokenEndpointResponse = authenticationValidatedContext.TokenEndpointResponse; + ticket = authenticationValidatedContext.Ticket; + + if (Options.SaveTokensAsClaims) { - return await HandleIdTokenFlows(message, properties); + SaveTokens(ticket.Principal, tokenEndpointResponse ?? authorizationResponse, jwt.Issuer); } - else + + if (Options.GetClaimsFromUserInfoEndpoint) { - Logger.LogTrace(18, "Cannot process the message. Both id_token and code are missing."); - return AuthenticateResult.Fail(Resources.IdTokenCodeMissing); + return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, ticket); } + + return AuthenticateResult.Success(ticket); } catch (Exception exception) { @@ -456,179 +529,43 @@ protected override async Task HandleRemoteAuthenticateAsync( } } - var authenticationFailedContext = await RunAuthenticationFailedEventAsync(message, exception); - if (authenticationFailedContext.HandledResponse) - { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - else if (authenticationFailedContext.Skipped) + var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); + if (CheckEventResult(authenticationFailedContext, out result)) { - 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() - { - ClientId = Options.ClientId, - ProtocolMessage = message, - }); - - 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; - 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) + if (context.HandledResponse) { - // Persist the tokens extracted from the token response. - SaveTokens(ticket.Principal, tokenEndpointResponse, jwt.Issuer, saveRefreshToken: true); + result = AuthenticateResult.Success(context.Ticket); + return true; } - - if (Options.GetClaimsFromUserInfoEndpoint) + else if (context.Skipped) { - Logger.LogTrace(22, "Sending request to user info endpoint for retrieving claims."); - ticket = await GetUserInformationAsync(tokenEndpointResponse, jwt, ticket); + result = AuthenticateResult.Skip(); + return true; } - - 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)) - { - nonce = ReadNonceCookie(nonce); - } - - Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() - { - 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); - } - else if (authenticationValidatedContext.Skipped) + if (!string.IsNullOrEmpty(message.SessionState)) { - return AuthenticateResult.Skip(); + properties.Items[OpenIdConnectSessionProperties.SessionState] = message.SessionState; } - message = authenticationValidatedContext.ProtocolMessage; - ticket = authenticationValidatedContext.Ticket; - // Hybrid Flow - if (message.Code != null) + if (!string.IsNullOrEmpty(_configuration.CheckSessionIframe)) { - 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); - } + properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe; } - // 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 @@ private async Task HandleIdTokenFlows(OpenIdConnectMessage m /// 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// 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 @@ protected virtual async Task GetUserInformationAsync(OpenI } 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) - { - return userInformationReceivedContext.Ticket; - } - else if (userInformationReceivedContext.Skipped) + AuthenticateResult result; + if (CheckEventResult(userInformationReceivedContext, out result)) { - return ticket; + return result; } ticket = userInformationReceivedContext.Ticket; user = userInformationReceivedContext.User; @@ -742,7 +687,7 @@ protected virtual async Task GetUserInformationAsync(OpenI identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, jwt.Issuer)); } - return ticket; + return AuthenticateResult.Success(ticket); } /// @@ -750,8 +695,7 @@ protected virtual async Task GetUserInformationAsync(OpenI /// /// 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 @@ private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunTokenResponseReceivedEventAs 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 @@ private async Task RunAuthenticationFailedEventAsyn 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 @@ private AuthenticationTicket ValidateToken(string idToken, OpenIdConnectMessage } 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 @@ private AuthenticationTicket ValidateToken(string idToken, OpenIdConnectMessage 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 112/611] 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 2048801a6..58a708245 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 d5d554462..abe001fe4 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 d39a05974..248e085c2 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 113/611] 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 58a708245..b3ca2d48d 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 114/611] 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 b3ca2d48d..eb36173bf 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 abe001fe4..651b9acb6 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 248e085c2..db1fce596 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 46fd46b48..ae53f6e2f 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 115/611] #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 | 70 +++++-- .../OpenIdConnectHandler.cs | 72 ++++---- 9 files changed, 421 insertions(+), 46 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 4c24c1d22..2ed873270 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 000000000..f174174cf --- /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 000000000..c7b0ff10e --- /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 000000000..22d7eec72 --- /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 000000000..c5ddafd5f --- /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 000000000..dabb9262f --- /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 000000000..8485f6719 --- /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 d1737cd25..49c863e4b 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 @@ public class AuthorizationCodeReceivedContext : BaseOpenIdConnectContext /// /// 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'. + /// Gets or sets the that was received in the authentication response, if any. /// - public string Code { get; set; } + public JwtSecurityToken JwtSecurityToken { get; set; } /// - /// Gets or sets the that was received in the id_token + code OpenIdConnectRequest. + /// The request that will be sent to the token endpoint and is available for customization. /// - public JwtSecurityToken JwtSecurityToken { 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; /// - /// Gets or sets the 'redirect_uri'. + /// 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. /// - /// 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 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 4084e2100..4dc4a32b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -303,7 +303,6 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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; - - tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); + 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) + { + tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); + } var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); if (CheckEventResult(authorizationCodeRedeemedContext, out result)) @@ -485,13 +491,17 @@ protected override async Task HandleRemoteAuthenticateAsync( } } - 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 @@ private void PopulateSessionProperties(OpenIdConnectMessage message, Authenticat /// 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 @@ private async Task RunAuthorizationRespons 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 tokenEndpointRequest = new OpenIdConnectMessage() + { + ClientId = Options.ClientId, + ClientSecret = Options.ClientSecret, + Code = authorizationResponse.Code, + GrantType = OpenIdConnectGrantTypes.AuthorizationCode, + RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] + }; - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options, properties) + var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options) { - Code = message.Code, - ProtocolMessage = message, - RedirectUri = redirectUri, + 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 116/611] 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 ebb619e73..95b049cf6 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 117/611] 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 95b049cf6..2fa024b15 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 000000000..4fd24a30d --- /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 263fb667a..79638d06b 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 118/611] 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 2fa024b15..7d4894cb4 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 119/611] 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 fa17dd9cf..a3e9f4556 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 8de831b40..e60b1b355 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 436a2203b..0f6a6c9df 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 e5bec9e8c..12d88dfed 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 00570902f..a4c71e0b7 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 5ceb5b7a6..46666ed12 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 5dbf6f6cf..e93b2feb4 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 929424cc1..d250dee27 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 f6e200b7c..21be97e4b 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 c415b2a63..468955a93 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 c5128412c..dc073ab7b 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 90487a898..fc58e6a89 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 67ebf2c0d..8dd3556bc 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 d34a6697b..73f7ed80d 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 688fd8403..f07e8d2d5 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 a2c04f145..ce4c552dc 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 eb36173bf..c05a8963b 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 651b9acb6..560766c03 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 db1fce596..f6dad148a 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 120/611] 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 b994c1eea..02e65225c 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 121/611] 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 dc1a63bbf..51cf43a0f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -13,7 +13,7 @@ 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 de7bee163..1b179c336 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -17,7 +17,7 @@ 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 8f1fb0691..04d050b06 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs @@ -6,7 +6,7 @@ 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 7772457a0..70a76f27c 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs @@ -5,8 +5,14 @@ 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 03eece931..5111c7971 100644 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs @@ -6,8 +6,16 @@ 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 0388c04bd..43e011c40 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -8,6 +8,9 @@ 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 c3019c907..94799af29 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -6,6 +6,9 @@ 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 @@ public class AuthorizationOptions /// 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 @@ public void AddPolicy(string name, AuthorizationPolicy policy) 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 @@ public void AddPolicy(string name, Action configureP 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 812c71428..8201b5863 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -6,12 +6,28 @@ 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 122/611] 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 50d06f00e..bb23e6481 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 ec3d4dd5e..c81393af1 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 15adb23f1..ed0c9b32b 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 c7b0ff10e..e3495a211 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 1f0879ea4..905bce8e3 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 3d2aa528d..775eebbc2 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 bc93d6322..8c4f3cd41 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 68ee50c4b..395259212 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 f92646ce6..ff412f08a 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 ef8673b48..8d87a04b7 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 c15c0534e..52dd6cb67 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 962888b9d..34a397bd5 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 9ae8192f2..2f970b513 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 55deb0714..5fba7a974 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 fe12613f9..e03db0847 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 be8ba0e0e..c6a57567b 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 4b5fbfe3b..5ffad968d 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 bb58ad712..c6b01504a 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 aaf23b99e..aec10ee93 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 579dd0f44..d596a5bb4 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 b04b3cd61..cf42659a0 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 c3f5e576d..96d5b6c5a 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 123/611] 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 f07e8d2d5..511a05d56 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 124/611] Save tokens in auth properties instead of claims --- samples/SocialSample/Startup.cs | 68 +++++---- .../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, 405 insertions(+), 68 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 ffbaf8dc5..4ab304c32 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -5,6 +5,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, TokenEndpoint = GoogleDefaults.TokenEndpoint, Scope = { "openid", "profile", "email" }, - SaveTokensAsClaims = true + SaveTokens = true }); // See config.json @@ -146,27 +147,27 @@ [WebListener] Then you can choose to run the app as admin (see below) or add the 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 - }); - - //// 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" } - }); + //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" } + //}); // See config.json // https://github.com/settings/applications/ @@ -179,7 +180,7 @@ dnx web 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 @@ dnx web { 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 00ecae0fb..613dfbc15 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -153,6 +153,14 @@ protected override async Task HandleAuthenticateAsync() 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 0a08ff3e4..a4b5ef2ae 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -110,5 +110,11 @@ public JwtBearerOptions() : base() /// 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 7a06bee70..ddd26d9f0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -85,21 +85,19 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 4dc4a32b8..3c7f04438 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -105,9 +105,7 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC ///
/// 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 @@ private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, 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 c39cce121..d856a9b84 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -88,10 +88,12 @@ protected override async Task HandleRemoteAuthenticateAsync( }, 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 000000000..6503f0bb8 --- /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 43e011c40..d925be8ec 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -51,19 +51,19 @@ public string DisplayName 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 000000000..8065139ba --- /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 6a0780812..6a3442e82 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -292,6 +292,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla { ClientId = "Test Id", ClientSecret = "Test Secret", + SaveTokens = true, StateDataFormat = stateFormat, ClaimsIssuer = claimsIssuer, BackchannelHttpHandler = new TestHttpMessageHandler @@ -334,6 +335,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla } } }); + var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; @@ -361,6 +363,12 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla // 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 @@ private static TestServer CreateServer(GoogleOptions options, Func 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 000000000..ef030d115 --- /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 63f8af1bb..f7128a6f1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -46,5 +46,17 @@ public string FindClaimValue(string claimType, string issuer = null) } 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 125/611] 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 4ab304c32..ed3f09a14 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -322,10 +322,10 @@ dnx web 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 6a3442e82..96bb574fb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -793,7 +793,7 @@ private static TestServer CreateServer(GoogleOptions options, Func Date: Thu, 3 Mar 2016 17:33:22 -0800 Subject: [PATCH 126/611] 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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 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.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 b2437d9ad..76feceeff 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ 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 b2437d9ad..76feceeff 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ 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 b2437d9ad..76feceeff 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ 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 c0526726a..1fe857fd9 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 @@ // 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 127/611] 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 ed3f09a14..108ad6ff8 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -72,13 +72,14 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { ClientId = Configuration["google:clientid"], ClientSecret = Configuration["google:clientsecret"], + SaveTokens = true, Events = new OAuthEvents() { OnRemoteFailure = ctx => @@ -118,6 +120,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { ConsumerKey = Configuration["twitter:consumerkey"], ConsumerSecret = Configuration["twitter:consumersecret"], + SaveTokens = true, Events = new TwitterEvents() { OnRemoteFailure = ctx => @@ -195,6 +198,7 @@ dnx web 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 128/611] 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 | 102 +++++++++++------- .../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, 115 insertions(+), 72 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 15c91efdc..e9d26ad03 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 108ad6ff8..358a031cd 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.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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); + // Forward the scheme from IISPlatformHandler + app.UseForwardedHeaders(new ForwardedHeadersOptions() + { + ForwardedHeaders = ForwardedHeaders.XForwardedProto, + }); + app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, @@ -105,7 +121,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) Events = new OAuthEvents() { OnRemoteFailure = ctx => - { ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); @@ -132,45 +147,34 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - // 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 - //}); - - ////// 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://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 + }); + + // 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 @@ public static void Main(string[] args) 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 13d3ff94a..5c1453e39 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 a4c71e0b7..1d0223029 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 d85379477..0d272f979 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -7,10 +7,10 @@ public static class MicrosoftAccountDefaults { 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 245fbed87..8b9177625 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -38,13 +38,27 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 8b88cbc44..cce8dcc73 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 @@ public static string GetId(JObject user) /// /// 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 @@ public static string GetEmail(JObject user) 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 2783bcef1..625d4baf9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,7 +22,7 @@ public MicrosoftAccountOptions() 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 f5a43b8ed..0ddfb5a3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -92,7 +92,7 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() { 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 129/611] 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 3c7f04438..1e804ef31 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -726,6 +726,8 @@ private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessag 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 130/611] 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 4c7cf6982..9f3414fbc 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 e946548f4..c26cd5d66 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -19,6 +19,7 @@ public class CookieRedirectContext : BaseCookieContext /// 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 ab5858e36..51c04a56b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -17,6 +17,7 @@ public class CookieSigningOutContext : BaseCookieContext /// /// /// + /// /// 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 d2c1fd42f..57a28191c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -62,7 +62,7 @@ public CookieValidatePrincipalContext(HttpContext context, AuthenticationTicket /// 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 46666ed12..0029e6a89 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 16b60e1dd..e4a76e0e9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -27,7 +27,6 @@ public class FacebookMiddleware : OAuthMiddleware /// /// /// Configuration options for the middleware. - /// public FacebookMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -79,9 +78,9 @@ public FacebookMiddleware( } /// - /// 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 e93b2feb4..3cd595a96 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 f81497f26..190dc4b25 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -28,7 +28,6 @@ public class GoogleMiddleware : OAuthMiddleware /// /// /// Configuration options for the middleware. - /// public GoogleMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -70,9 +69,9 @@ public GoogleMiddleware( } /// - /// 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 d250dee27..702d45aef 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 4ad6f7c21..2e023db13 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 5fc8a6b6c..a14f23807 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 a4b5ef2ae..c350c38ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -113,7 +113,7 @@ public JwtBearerOptions() : base() /// /// 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 21be97e4b..091deca82 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 e7ba9f811..fc9866826 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -26,7 +26,6 @@ public class MicrosoftAccountMiddleware : OAuthMiddleware /// /// Configuration options for the middleware. - /// public MicrosoftAccountMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -68,9 +67,9 @@ public MicrosoftAccountMiddleware( } /// - /// 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 468955a93..e0a2fceb0 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 76a238e07..29316732c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs @@ -6,7 +6,7 @@ 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 @@ public interface IOAuthEvents : IRemoteAuthenticationEvents /// /// 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 cf1528e28..44c426051 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -28,14 +28,14 @@ public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents /// /// 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 5dcbd568c..63eaa3537 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs @@ -16,6 +16,7 @@ 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) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs index 401537e83..1a16d2aa3 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 @@ public OAuthMiddleware( 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 22d5e3557..57ecba2f4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -10,7 +10,7 @@ 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 dc073ab7b..b8f056fac 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 07aefec42..dde12494d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -31,7 +31,7 @@ public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicati /// 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 1e804ef31..9c157e57b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -579,8 +579,7 @@ private void PopulateSessionProperties(OpenIdConnectMessage message, Authenticat /// /// 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC /// /// 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 @@ private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessag /// 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 @@ private void WriteNonceCookie(string nonce) ///
/// 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 09901cf37..86ba43312 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -31,6 +31,7 @@ public class OpenIdConnectMiddleware : AuthenticationMiddleware /// /// + /// The . [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Managed by caller")] public OpenIdConnectMiddleware( RequestDelegate next, @@ -172,9 +173,9 @@ public OpenIdConnectMiddleware( 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 fc58e6a89..870884c4d 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 76b487b96..006fafc73 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs @@ -20,7 +20,7 @@ public interface ITwitterEvents : IRemoteAuthenticationEvents /// /// 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 97d1d176a..04a45ac6d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -17,6 +17,7 @@ public class TwitterCreatingTicketContext : BaseTwitterContext /// 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 99122e855..21c5b57a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -35,7 +35,7 @@ public class TwitterEvents : RemoteAuthenticationEvents, ITwitterEvents /// /// 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 1a1e199cc..7845b4bbc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -31,7 +31,6 @@ public class TwitterMiddleware : AuthenticationMiddleware /// /// /// Configuration options for the middleware - /// public TwitterMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -115,9 +114,9 @@ public TwitterMiddleware( } /// - /// 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 8dd3556bc..3dbaf2bf6 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 ff98a1031..f50fd3dbb 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -64,6 +64,7 @@ protected string CurrentUri /// 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 d925be8ec..a78c14bbe 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Builder { /// - /// Contains the options used by the . + /// Contains the options used by the . /// public class RemoteAuthenticationOptions : AuthenticationOptions { @@ -60,7 +60,7 @@ public string DisplayName /// /// 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 73f7ed80d..8339dc0c3 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 a2b0a755c..8979c5c63 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -13,6 +13,7 @@ public static class AuthorizationServiceExtensions /// /// 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 511a05d56..7a53cad1d 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 ce4c552dc..1c2a549be 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 1fe857fd9..56cb77fdc 100644 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -12,3 +12,4 @@ [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 953428b7b..741385c83 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 131/611] 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 4fd24a30d..8f2f99691 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 79638d06b..f4208100e 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 132/611] 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 ac6987f3d..8e86b37c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -28,6 +28,8 @@ public FacebookOptions() 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 133/611] #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 ad63b1761..a01490c3e 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -73,7 +73,7 @@ public async Task Invoke(HttpContext context) await _next(context); } } - catch (Exception) + finally { try { @@ -81,9 +81,8 @@ public async Task Invoke(HttpContext context) } 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 134/611] 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 bf811dc26..dd4686f39 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 3fab83e13..c6d5f7d99 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 135/611] 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 dd4686f39..df22f7a88 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 c6d5f7d99..b9a9bcd1e 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 136/611] 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 02e65225c..f32798072 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 0029e6a89..b1148ce00 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 e4a76e0e9..ac57e8dde 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -14,7 +14,7 @@ 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 3cd595a96..2fe504000 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 190dc4b25..ba6fb7d2e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -14,7 +14,7 @@ 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 702d45aef..ed29e86ae 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 091deca82..e86e91415 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 fc9866826..3ad1bf557 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -13,7 +13,7 @@ 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 e0a2fceb0..7507e1eb4 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 1a16d2aa3..7ef186322 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -15,7 +15,7 @@ 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 @@ public OAuthMiddleware( } 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 b8f056fac..978dea7cc 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 86ba43312..76936e25a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -17,14 +17,14 @@ 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 @@ public OpenIdConnectMiddleware( } 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 870884c4d..eee5f0942 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 7845b4bbc..542115117 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -15,7 +15,7 @@ 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 @@ public TwitterMiddleware( _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 3dbaf2bf6..73e5c9b7a 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 8339dc0c3..f02351c2c 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 7a53cad1d..e75441dc8 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 1c2a549be..f1c7b77b9 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 741385c83..691b16c42 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 ef80b78e6..3c08f58bd 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -31,7 +31,7 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 137/611] 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 e75441dc8..9d65386a8 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 138/611] 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 1cc76b946..1edb4a0f4 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -35,7 +35,7 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild /// 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 @@ public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuild 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 000000000..3c363ca98 --- /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 78d9a0845..7a2c47e40 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 @@ public async Task AuthenticateAsync(AuthenticateContext context) 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 2e2216bc2..53f6a07a8 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs @@ -35,13 +35,17 @@ public ClaimsTransformationMiddleware( 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 b8e7ea3e1..db05db0e5 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 5111c7971..cd42915c0 100644 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs @@ -14,8 +14,8 @@ public interface IClaimsTransformer /// /// 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 785d5bfa6..5049f39e5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -293,16 +293,16 @@ public async Task CookieAppliesClaimsTransform() { 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 96bb574fb..31fb9e317 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -222,7 +222,7 @@ public async Task AuthenticateWillFail() ClientId = "Test Id", ClientSecret = "Test Secret" }, - async context => + async context => { var req = context.Request; var res = context.Response; @@ -273,7 +273,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) { 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 @@ private static TestServer CreateServer(GoogleOptions options, Func + 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 139/611] 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 978dea7cc..c02bfe897 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 140/611] 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 3c08f58bd..2abb115e4 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -29,7 +29,7 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 141/611] 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 dabb9262f..a25fc1661 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 c02bfe897..c6658208e 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 73e5c9b7a..718d51747 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 142/611] 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 d9a65028c..b8bb1264e 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -5,6 +5,7 @@ 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 fde603497..307002d1f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -7,7 +7,6 @@ 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 @@ public async Task Execute(TestServer server) } 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 143/611] 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 2baa9e45c..ad0e17a09 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 @@ public static class CookieAuthenticationDefaults /// 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 51cf43a0f..8a451c9c7 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 @@ public string CookieName /// 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 @@ public string CookieName /// 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 c26cd5d66..2cbb5ff09 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 @@ public class CookieRedirectContext : BaseCookieContext /// 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 @@ public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions op /// /// 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 ba6fb7d2e..eb98e447b 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 7ef186322..75139c1c8 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 76936e25a..80f2ca2ba 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 @@ public class OpenIdConnectMiddleware : AuthenticationMiddleware /// /// 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 1b179c336..acf9d77e4 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 @@ public OpenIdConnectOptions() /// 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 a96a379c1..88b10d3d6 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 @@ public class RequestTokenSerializer : IDataSerializer /// /// 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 @@ public virtual byte[] Serialize(RequestToken model) /// /// 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 542115117..67fb903dd 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 542553cf2..dd30b45ae 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 @@ public class PropertiesSerializer : IDataSerializer 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 @@ public virtual byte[] Serialize(AuthenticationProperties model) } } - [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 144/611] 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 e86e91415..3efa9c064 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 eee5f0942..7be775cfe 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 145/611] [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 613dfbc15..b1d2d702e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -119,7 +119,7 @@ protected override async Task HandleAuthenticateAsync() } 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() } 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 000000000..643da9290 --- /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 000000000..8d45c9918 --- /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 9c157e57b..5c534696b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -114,12 +114,12 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con { 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (_configuration == null && Options.ConfigurationManager != null) { - Logger.LogDebug(14, "Updating configuration"); + Logger.UpdatingConfiguration(); _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } @@ -422,7 +426,7 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ private void PopulateSessionProperties(OpenIdConnectMessage message, Authenticat /// 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private string ReadNonceCookie(string nonce) } catch (Exception ex) { - Logger.LogWarning(25, "Failed to un-protect the nonce cookie.", ex); + Logger.UnableToProtectNonceCookie(ex); } } } @@ -829,7 +832,7 @@ private AuthenticationProperties GetPropertiesFromState(string state) 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunAuthorizationRespons 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunTokenResponseReceivedEventAs 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 @@ private async Task RunAuthenticationValidatedEve 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 @@ private async Task RunAuthenticationValidatedEve 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 @@ private async Task RunUserInformationReceivedEve 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 @@ private async Task RunAuthenticationFailedEventAsyn 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 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert { 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 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert 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 000000000..21a4ac541 --- /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 d856a9b84..d7383e939 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -155,7 +155,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin { // 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 f50fd3dbb..ebb25af21 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -104,13 +104,13 @@ public async Task InitializeAsync(TOptions options, HttpContext context, ILogger 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 @@ internal async Task TeardownAsync() /// /// 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 @@ 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. + // Calling Authenticate more than once should always return the original value. var result = await HandleAuthenticateOnceAsync(); if (result?.Failure != null) @@ -216,13 +216,13 @@ public async Task AuthenticateAsync(AuthenticateContext context) 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 @@ public async Task SignInAsync(SignInContext context) { 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 @@ public async Task SignOutAsync(SignOutContext context) { 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 @@ public async Task ChallengeAsync(ChallengeContext context) 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 000000000..49fc8db05 --- /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 bf64109a2..d6cc4ce7f 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -39,7 +39,7 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 c5bdcc7a7..7d46ac8b8 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -51,12 +51,12 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 000000000..1d524dd74 --- /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 146/611] 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 8b0568b31..043664f1d 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -45,7 +45,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 3db8f1155..71da6aa1f 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -55,7 +55,7 @@ await context.Authentication.SignInAsync(CookieAuthenticationDefaults.Authentica 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 3a4ecfba6..1df7e11a3 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -115,7 +115,7 @@ public void Configure(IApplicationBuilder app) 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 c5ddafd5f..f2f9489bf 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -159,7 +159,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 ddcf9fa2b..ff156a77f 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -105,7 +105,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 358a031cd..e9c7f6141 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -342,7 +342,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 147/611] 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 c05a8963b..07137861a 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 560766c03..0bc8910ce 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 f6dad148a..8d529ea87 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 ae53f6e2f..0f156822d 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 148/611] #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 | 208 ++++++++---------- .../Events/BaseControlContext.cs | 16 ++ .../JwtBearer/JwtBearerMiddlewareTests.cs | 181 +++------------ .../OpenIdConnectMiddlewareTests.cs | 8 +- 26 files changed, 277 insertions(+), 489 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 af63bba52..49cbac543 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 1df7e11a3..78e6d0f40 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -61,8 +61,6 @@ public void Configure(IApplicationBuilder app) 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 @@ public void Configure(IApplicationBuilder app) // 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 0f6a6c9df..a271c2b5c 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 22d7eec72..49cbac543 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 f2f9489bf..3bbae57b4 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -64,10 +64,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 a25fc1661..fd7461019 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 c75dba9f4..5a0163016 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 ff156a77f..bad559aa2 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -59,10 +59,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 12d88dfed..4fd829a22 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 2e023db13..a7b8aeb55 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs @@ -18,17 +18,12 @@ public interface IJwtBearerEvents /// /// 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 a14f23807..38a877f66 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -19,17 +19,12 @@ public class JwtBearerEvents : IJwtBearerEvents /// /// 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 @@ public class JwtBearerEvents : IJwtBearerEvents public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); - public virtual Task ReceivingToken(ReceivingTokenContext context) => OnReceivingToken(context); - - public virtual Task ReceivedToken(ReceivedTokenContext context) => OnReceivedToken(context); + public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(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 e93ad824a..a23f8356d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -6,9 +6,9 @@ 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 e38c49cf1..000000000 --- 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 3a1dad812..d6de5ca87 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 b1d2d702e..40a0b2efd 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -28,24 +28,21 @@ internal class JwtBearerHandler : AuthenticationHandler 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 @@ protected override async Task HandleAuthenticateAsync() } } - // 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 @@ protected override async Task HandleAuthenticateAsync() 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) - { - return AuthenticateResult.Success(validatedTokenContext.Ticket); - } - if (validatedTokenContext.Skipped) + await Options.Events.TokenValidated(tokenValidatedContext); + if (tokenValidatedContext.CheckEventResult(out result)) { - return AuthenticateResult.Skip(); + return result; } + ticket = tokenValidatedContext.Ticket; if (Options.SaveToken) { @@ -173,13 +152,9 @@ protected override async Task HandleAuthenticateAsync() }; await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) - { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - if (authenticationFailedContext.Skipped) + if (authenticationFailedContext.CheckEventResult(out result)) { - return AuthenticateResult.Skip(); + return result; } return AuthenticateResult.Fail(authenticationFailedContext.Exception); @@ -197,13 +172,9 @@ protected override async Task HandleAuthenticateAsync() }; await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) - { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - if (authenticationFailedContext.Skipped) + if (authenticationFailedContext.CheckEventResult(out result)) { - 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 c350c38ba..837928e77 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -25,6 +25,8 @@ public class JwtBearerOptions : AuthenticationOptions 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 7d17d3cf8..000000000 --- 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 da956acf8..57600cee8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs @@ -15,21 +15,11 @@ public interface IOpenIdConnectEvents : IRemoteAuthenticationEvents /// 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 @@ public interface IOpenIdConnectEvents : IRemoteAuthenticationEvents /// /// 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 d535f35f9..b2554969c 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 @@ public MessageReceivedContext(HttpContext context, OpenIdConnectOptions options) /// 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 249342eec..9893b7207 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -16,21 +16,11 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve /// 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 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve /// /// 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 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve 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 4e1979645..130a4d987 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 @@ 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 8d45c9918..ff580ff26 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 @@ internal static class LoggingExtensions 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 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ 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) + public static void TokenValidatedHandledResponse(this ILogger logger) { - _authorizationResponseReceivedHandledResponse(logger, null); + _tokenValidatedHandledResponse(logger, null); } - public static void AuthorizationResponseReceivedSkipped(this ILogger logger) + public static void TokenValidatedSkipped(this ILogger logger) { - _authorizationResponseReceivedSkipped(logger, null); + _tokenValidatedSkipped(logger, null); } public static void AuthorizationCodeReceivedContextHandledResponse(this ILogger logger) @@ -283,24 +263,14 @@ 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) + public static void TokenResponseReceivedHandledResponse(this ILogger logger) { - _authenticationValidatedHandledResponse(logger, null); + _tokenResponseReceivedHandledResponse(logger, null); } - public static void AuthenticationValidatedSkipped(this ILogger logger) + public static void TokenResponseReceivedSkipped(this ILogger logger) { - _authenticationValidatedtSkipped(logger, null); + _tokenResponseReceivedSkipped(logger, null); } public static void AuthenticationFailedContextHandledResponse(this ILogger logger) @@ -328,24 +298,24 @@ public static void MessageReceivedContextSkipped(this ILogger logger) _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 5c534696b..f85ba9c14 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -111,15 +111,15 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) /// 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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,6 +392,15 @@ protected override async Task HandleRemoteAuthenticateAsync( return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } + string userstate = null; + properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out userstate); + authorizationResponse.State = userstate; + + if (!ValidateCorrelationId(properties)) + { + return AuthenticateResult.Fail("Correlation failed."); + } + // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { @@ -390,16 +409,9 @@ protected override async Task HandleRemoteAuthenticateAsync( 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; - - if (!ValidateCorrelationId(properties)) - { - return AuthenticateResult.Fail("Correlation failed."); + 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) @@ -408,14 +420,6 @@ protected override async Task HandleRemoteAuthenticateAsync( _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 @@ protected override async Task HandleRemoteAuthenticateAsync( { 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( { 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } } - 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (CheckEventResult(authenticationFailedContext, out result)) + if (authenticationFailedContext.CheckEventResult(out result)) { return result; } @@ -551,22 +567,6 @@ protected override async Task HandleRemoteAuthenticateAsync( } } - 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private AuthenticationProperties GetPropertiesFromState(string state) } } - 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunAuthorizationCodeReceive 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) - { - Logger.AuthorizationCodeRedeemedContextHandledResponse(); - } - else if (tokenResponseReceivedContext.Skipped) - { - Logger.AuthorizationCodeRedeemedContextSkipped(); - } - - 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) + await Options.Events.TokenResponseReceived(eventContext); + if (eventContext.HandledResponse) { - Logger.AuthenticationValidatedHandledResponse(); + Logger.TokenResponseReceivedHandledResponse(); } - else if (authenticationValidatedContext.Skipped) + else if (eventContext.Skipped) { - Logger.AuthenticationValidatedSkipped(); + Logger.TokenResponseReceivedSkipped(); } - 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 db81ad704..24f3ba8e5 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -46,5 +46,21 @@ public void SkipToNextMiddleware() /// 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 72d13a4c9..81c03dc83 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -73,7 +73,7 @@ public async Task CustomHeaderReceived() AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnReceivingToken = context => + OnMessageReceived = context => { var claims = new[] { @@ -143,39 +143,6 @@ public async Task InvalidTokenReceived() 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 @@ public async Task CustomTokenValidated() 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 @@ public async Task CustomTokenValidated() } } }; + options.SecurityTokenValidators.Clear(); options.SecurityTokenValidators.Add(new BlobTokenValidator(options.AuthenticationScheme)); var server = CreateServer(options); @@ -215,67 +183,37 @@ public async Task CustomTokenValidated() [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 @@ public async Task BearerTurns401To403IfAuthenticated() [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 @@ public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() } [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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnValidatedToken = context => + OnTokenValidated = context => { throw new Exception("Test Exception"); }, @@ -493,9 +372,17 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame 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 @@ public int MaximumTokenSizeInBytes 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 cadcf8088..ebc59b9ee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -150,12 +150,12 @@ private static OpenIdConnectOptions GetProtocolMessageOptions() 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 @@ public async Task ChallengeSettingState(string userState, string challenge) 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 @@ public async Task ChallengeWillUseEvents() 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 149/611] 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 9ce76d7e6..2aa320ae2 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -15,7 +15,7 @@ public static class AuthenticationServiceCollectionExtensions /// 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 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi /// /// 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 d03f9ed74..c92be6232 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -17,7 +17,7 @@ public static class AuthorizationServiceCollectionExtensions /// 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 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic /// /// 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 150/611] 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 043664f1d..4ad27b180 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,7 +46,7 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -54,4 +54,4 @@ public static void Main(string[] args) host.Run(); } } -} \ No newline at end of file +} diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 71da6aa1f..7843f66a1 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,7 +56,7 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -64,4 +64,4 @@ public static void Main(string[] args) host.Run(); } } -} \ No newline at end of file +} diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 78e6d0f40..b0c2464f8 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -114,7 +114,7 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -123,3 +123,4 @@ public static void Main(string[] args) } } } + diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 3bbae57b4..3a73a090a 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 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -166,3 +166,4 @@ public static void Main(string[] args) } } } + diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bad559aa2..76ac7c712 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -103,7 +103,7 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -112,3 +112,4 @@ public static void Main(string[] args) } } } + diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e9c7f6141..0e13b78e9 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -343,7 +343,7 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -370,3 +370,4 @@ private X509Certificate2 LoadCertificate() } } } + From 16a0482238bde951dbba981aaf8e80345a32a23c Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sun, 27 Mar 2016 21:46:45 -0700 Subject: [PATCH 151/611] 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 d7383e939..18aa0abcb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -13,7 +13,6 @@ 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 eea17bcc3..0d245cf0a 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 b8bb1264e..7b52a5880 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -6,7 +6,6 @@ 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 431c35bdb..aa9aef07c 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.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 71590727c..4b92f08c8 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 ef030d115..e8f2c1657 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 152/611] 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 7d46ac8b8..39d35d0dd 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -5,6 +5,7 @@ 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 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 153/611] 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 ebb25af21..639be0103 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -102,7 +102,7 @@ public async Task InitializeAsync(TOptions options, HttpContext context, ILogger 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 154/611] 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 5500f6d50..71b9724a0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691..cf8bff13b 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 f4208100e..f88fe4052 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 155/611] 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 b1148ce00..82438e402 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 2fe504000..663991465 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 ed29e86ae..9740543ec 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 3efa9c064..204ad1ace 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 7507e1eb4..be1c9099e 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 c6658208e..30a5c489e 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 7be775cfe..581abf9ce 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 718d51747..23ca0cf31 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 f02351c2c..ec5ff479c 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 9d65386a8..0d14ab8ad 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 f1c7b77b9..72a86bf80 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 156/611] 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 4ad27b180..49ac74a7f 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -47,7 +47,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index a3e9f4556..f61695c21 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 000000000..8d6117761 --- /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 e69de29bb..000000000 diff --git a/samples/CookieSample/wwwroot/web.config b/samples/CookieSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf..000000000 --- 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 7843f66a1..d3b72bae2 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -57,7 +57,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index e60b1b355..deff15e38 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 000000000..fb7e915bf --- /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 e69de29bb..000000000 diff --git a/samples/CookieSessionSample/wwwroot/web.config b/samples/CookieSessionSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf..000000000 --- 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 b0c2464f8..9916955c3 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -54,8 +54,6 @@ public void Configure(IApplicationBuilder app) } }); - app.UseIISPlatformHandler(); - app.UseDefaultFiles(); app.UseStaticFiles(); @@ -115,7 +113,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index a271c2b5c..f940b1b10 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 000000000..801dbfd85 --- /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 8485f6719..000000000 --- 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 3a73a090a..5841d6f2e 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -62,8 +62,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); var clientId = Configuration["oidc:clientid"]; @@ -158,7 +156,7 @@ public static void Main(string[] args) 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 fd7461019..6c7adf7f2 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 000000000..cdcb5a614 --- /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 8485f6719..000000000 --- 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 76ac7c712..1591ac119 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -57,8 +57,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions @@ -104,7 +102,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 4fd829a22..cd923e7e0 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 000000000..b1b731cce --- /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 125a5a8cf..000000000 --- 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 9a0d90abf..000000000 --- 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 0e13b78e9..156af2a5c 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -73,12 +73,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - // Forward the scheme from IISPlatformHandler - app.UseForwardedHeaders(new ForwardedHeadersOptions() - { - ForwardedHeaders = ForwardedHeaders.XForwardedProto, - }); - app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, @@ -344,7 +338,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 1d0223029..edf9129fd 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 000000000..5611f93f1 --- /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 9a0d90abf..000000000 --- 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 157/611] 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 49ac74a7f..c2593c909 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -47,7 +47,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index d3b72bae2..423c96120 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -57,7 +57,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 9916955c3..c2dbfb7a9 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -113,7 +113,7 @@ public static void Main(string[] args) 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 5841d6f2e..938a19c20 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -156,7 +156,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 1591ac119..097ce771b 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -102,7 +102,7 @@ public static void Main(string[] args) var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 156af2a5c..e002894ce 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -338,7 +338,7 @@ public static void Main(string[] args) 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 158/611] 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 e002894ce..f109d65fe 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -51,10 +51,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ public static void Main(string[] args) { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseKestrel() + .UseKestrel(options => + { + //Configure SSL + var serverCertificate = LoadCertificate(); + options.UseHttps(serverCertificate); + }) .UseIISIntegration() .UseStartup() .Build(); @@ -345,9 +346,9 @@ public static void Main(string[] args) 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 159/611] 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 30a5c489e..a3b553c5d 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 160/611] 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 a3b553c5d..a4ee11166 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 161/611] 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 f61695c21..45bf30188 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 deff15e38..47ed4e919 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 f940b1b10..829ec7fa8 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 cd923e7e0..faeb6a0ee 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 edf9129fd..66ab3ede6 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 07137861a..79219ed22 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 0bc8910ce..3002b7368 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 8d529ea87..66b67c062 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 162/611] 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 45bf30188..531ea474c 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 47ed4e919..c1aee49c1 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 829ec7fa8..29ecf0157 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 6c7adf7f2..b6879e577 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 faeb6a0ee..553e170fc 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 66ab3ede6..fe1d2bfdc 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 79219ed22..b1ac8e97c 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 3002b7368..721986616 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 66b67c062..f2283ce4f 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 0f156822d..dac3f8185 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 163/611] 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 b1ac8e97c..931b20be1 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 721986616..a16a0ba37 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 f2283ce4f..bb388af16 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 164/611] #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 acf9d77e4..cdbc9e0f0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -148,7 +148,7 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 165/611] [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 643da9290..008190f51 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 @@ static LoggingExtensions() 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 @@ public static void TokenValidationFailed(this ILogger logger, string token, Exce 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 166/611] 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 18aa0abcb..fdb7e3e07 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -202,7 +202,7 @@ private async Task ObtainRequestTokenAsync(string consumerKey, str 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin } 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 167/611] 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 531ea474c..6da446848 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 8d6117761..f7ac67933 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 c1aee49c1..3c8317380 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 fb7e915bf..f7ac67933 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 29ecf0157..c0b448b72 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 801dbfd85..f7ac67933 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 b6879e577..da801b5c2 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 cdcb5a614..f7ac67933 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 553e170fc..b907b68f9 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 b1b731cce..f7ac67933 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 fe1d2bfdc..c37c5f2b1 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 5611f93f1..f7ac67933 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 168/611] 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 c2593c909..768415f0c 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -45,7 +45,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 423c96120..4d3ea3aa6 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -55,7 +55,6 @@ await context.Authentication.SignInAsync(CookieAuthenticationDefaults.Authentica 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 c2dbfb7a9..b2df5033e 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -111,7 +111,6 @@ public void Configure(IApplicationBuilder app) 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 938a19c20..7d8cf2346 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -154,7 +154,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 097ce771b..ff68b471f 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -100,7 +100,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 f109d65fe..bf09b3f6f 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -332,7 +332,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 169/611] #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 bf09b3f6f..474e43ae7 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -125,9 +125,18 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) /* 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 5c1453e39..11477998c 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 04a45ac6d..435196a1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -5,6 +5,7 @@ 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 @@ public class TwitterCreatingTicketContext : BaseTwitterContext /// 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 21a4ac541..2a2cd5da7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs @@ -9,6 +9,7 @@ internal static class LoggingExtensions { private static Action _obtainRequestToken; private static Action _obtainAccessToken; + private static Action _retrieveUserDetails; static LoggingExtensions() { @@ -20,6 +21,10 @@ static LoggingExtensions() eventId: 2, logLevel: LogLevel.Debug, formatString: "ObtainAccessToken"); + _retrieveUserDetails = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Debug, + formatString: "RetrieveUserDetails"); } @@ -32,5 +37,10 @@ public static void ObtainRequestToken(this ILogger logger) { _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 fdb7e3e07..4fbf35aaa 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -16,6 +16,7 @@ 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( }, Options.ClaimsIssuer); + JObject user = null; + if (Options.RetrieveUserDetails) + { + user = await RetrieveUserDetailsAsync(accessToken, identity); + } + if (Options.SaveTokens) { properties.StoreTokens(new [] { @@ -95,12 +102,13 @@ protected override async Task HandleRemoteAuthenticateAsync( }); } - 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con } // 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ private async Task ObtainRequestTokenAsync(string consumerKey, str 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 @@ private async Task ObtainRequestTokenAsync(string consumerKey, str 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 @@ private async Task ObtainRequestTokenAsync(string consumerKey, str 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 @@ private async Task ObtainRequestTokenAsync(string consumerKey, str 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin 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 @@ private async Task ObtainAccessTokenAsync(string consumerKey, strin }; } + // 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 77fb0bd7a..8ab399a8f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -38,6 +38,14 @@ public TwitterOptions() /// 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 23ca0cf31..a185aa415 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 170/611] 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 c0b448b72..f3895f83b 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 da801b5c2..d47884d76 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 b907b68f9..62506bd54 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 bf09b3f6f..1767861a9 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -18,8 +18,6 @@ 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 c37c5f2b1..6ff162a31 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 171/611] 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 172/611] 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 6da446848..c28a644d4 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 3c8317380..d3caf9364 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 f3895f83b..a82778a76 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 d47884d76..1524a76b5 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 62506bd54..4a8e637f6 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 6ff162a31..faf517703 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 82438e402..c98a4bba1 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 663991465..27b5f34ea 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 9740543ec..3051e5fa7 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 204ad1ace..f0c04896e 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 be1c9099e..3a7b5e03e 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 a4ee11166..613cadae3 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 581abf9ce..f053b2be3 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 23ca0cf31..dcd412412 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 ec5ff479c..06de08d84 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 0d14ab8ad..0f9becfc8 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 72a86bf80..3cd40fd20 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 691b16c42..f94978e52 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 931b20be1..e99be60ee 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 a16a0ba37..11b3caf4d 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 bb388af16..6e64aba57 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 dac3f8185..cd3ae5609 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 173/611] 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 cd3ae5609..4dac4d3a2 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 174/611] #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 1524a76b5..40308478b 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 4a8e637f6..5f0744e0b 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 f053b2be3..11d887e5c 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 e99be60ee..01d03d2b3 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 175/611] 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 2bd90aad4..f6877f114 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 @@ public void Handle(AuthorizationContext context) } } - 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 @@ public virtual async Task HandleAsync(AuthorizationContext context) } } - 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 @@ protected virtual Task HandleAsync(AuthorizationContext context, TRequirement re 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 @@ public virtual async Task HandleAsync(AuthorizationContext context) } } - 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 @@ public virtual void Handle(AuthorizationContext context) } } - 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 455adb0dd..2349feb31 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 965ffe02e..653727f5e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -129,7 +129,7 @@ public AuthorizationPolicyBuilder RequireAuthenticatedUser() /// /// Function that must return true /// - public AuthorizationPolicyBuilder RequireAssertion(Func assert) + public AuthorizationPolicyBuilder RequireAssertion(Func assert) { if (assert == null) { @@ -145,7 +145,7 @@ public AuthorizationPolicyBuilder RequireAssertion(Func /// 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 39d35d0dd..d90cf1803 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -44,7 +44,7 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 fc8ba6e7f..cf7896a30 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 0cc1751a4..2ddf06526 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -11,9 +11,9 @@ public class AssertionRequirement : IAuthorizationHandler, IAuthorizationRequire /// /// 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 @@ public AssertionRequirement(Func assert) Handler = context => Task.FromResult(assert(context)); } - public AssertionRequirement(Func> assert) + public AssertionRequirement(Func> assert) { if (assert == null) { @@ -33,7 +33,7 @@ public AssertionRequirement(Func> assert) 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 bff54954d..644b33086 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -25,7 +25,7 @@ public ClaimsAuthorizationRequirement(string claimType, IEnumerable allo 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 44ab475de..57ad22dff 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 a4f2455a6..b0c4e6b10 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -23,7 +23,7 @@ public NameAuthorizationRequirement(string requiredName) 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 480e2de0c..d718591ec 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 217e3ea0c..a57a0e4c8 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -27,7 +27,7 @@ public RolesAuthorizationRequirement(IEnumerable allowedRoles) 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 7f1191694..42948c936 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -580,7 +580,7 @@ public async Task CanBlockNonAuthenticatedUser() 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 @@ public PassThroughRequirement(bool succeed) 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 @@ public ExpenseReportAuthorizationHandler(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 @@ protected override void Handle(AuthorizationContext context, OperationAuthorizat 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 @@ public async Task CanAuthorizeAllSuperuserOperations() 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 @@ protected override void Handle(AuthorizationContext context, OperationAuthorizat 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 176/611] 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 b056d0787..3a8365a5b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -145,13 +145,13 @@ private CookieOptions BuildCookieOptions() 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 8a451c9c7..f9455f23a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -29,7 +29,7 @@ public CookieAuthenticationOptions() ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; CookieHttpOnly = true; - CookieSecure = CookieSecureOption.SameAsRequest; + CookieSecure = CookieSecurePolicy.SameAsRequest; SystemClock = new SystemClock(); Events = new CookieAuthenticationEvents(); } @@ -59,7 +59,7 @@ public string CookieName 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 @@ public string CookieName /// 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 5a35415d1..000000000 --- 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 7b52a5880..46daaad81 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -74,7 +74,7 @@ public IResponseCookies Cookies 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 @@ private void ApplyPolicy(CookieOptions options) { 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 8201b5863..6aed18bfb 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 @@ 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; + 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 c0dd639f1..000000000 --- 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 5049f39e5..fa4a4502f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -192,14 +192,14 @@ public async Task SignOutWrongAuthTypeThrows() } [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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( { LoginPath = new PathString("/login"), CookieName = "TestCookie", - CookieSecure = cookieSecureOption + CookieSecure = cookieSecurePolicy }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -231,7 +231,7 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 307002d1f..f08d7fef8 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -37,18 +37,18 @@ public async Task SecureAlwaysSetsSecure() 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 @@ public async Task SecureNoneLeavesSecureUnchanged() 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 @@ public async Task SecureSameUsesRequest() 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 @@ private async Task RunTest( { 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 177/611] 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 80f2ca2ba..b08f8e944 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -82,6 +82,11 @@ public OpenIdConnectMiddleware( 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 @@ public OpenIdConnectMiddleware( Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); } - if (Options.Events == null) { Options.Events = new OpenIdConnectEvents(); @@ -164,6 +168,12 @@ public OpenIdConnectMiddleware( 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 ebc59b9ee..20de13571 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -161,6 +161,8 @@ private static OpenIdConnectOptions GetProtocolMessageOptions() return Task.FromResult(0); } }; + options.ClientId = "Test Id"; + options.Configuration = TestUtilities.DefaultOpenIdConnectConfiguration; return options; } @@ -550,5 +552,66 @@ private static DateTime GetNonceExpirationTime(string keyname, TimeSpan nonceLif 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 178/611] 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 000000000..cd8aab3ae --- /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 c85de8d26..75da70bee 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 768415f0c..002d87888 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -41,16 +41,5 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 c28a644d4..954c36643 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 000000000..6b9014f5e --- /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 8d4a0316a..15b478a0e 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 4d3ea3aa6..ecb61ab66 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -51,16 +51,5 @@ await context.Authentication.SignInAsync(CookieAuthenticationDefaults.Authentica 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 d3caf9364..a3626218c 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 000000000..82da93d59 --- /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 49cbac543..f5dfcd018 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 b2df5033e..02611de8c 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 @@ public void Configure(IApplicationBuilder app) }); }); } - - // 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 000000000..5dcda4c86 --- /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 49cbac543..2ae08a6cc 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 7d8cf2346..f4d0c37aa 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -20,12 +20,19 @@ public class Startup { 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 000000000..a81f11dfb --- /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 5a0163016..557b6921e 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 ff68b471f..c2f831e19 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 000000000..386819e6f --- /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 e9d26ad03..903a81588 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 7cad7de84..f8c7495d3 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.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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 faf517703..fb19d3ec2 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 179/611] 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 06de08d84..e5107da8f 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 180/611] 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 e5107da8f..06de08d84 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 181/611] 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 da65e246b..012f95dcc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -7,10 +7,10 @@ public static class FacebookDefaults { 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 eaa339d15..f38ca8afc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -86,7 +86,7 @@ public async Task NestedMapWillNotAffectRedirect() 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 @@ public async Task MapWillNotAffectRedirect() 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 @@ public async Task ChallengeWillTriggerRedirection() 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 182/611] 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 06fd12eb1..c17ff6b2a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -9,7 +9,7 @@ public static class GoogleDefaults 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 31fb9e317..42cecf81b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -299,7 +299,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla { 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() { 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 @@ public async Task NullRedirectUriWillRedirectToSlash() { 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 @@ public async Task ValidateAuthenticatedContext() { 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 183/611] #667 #801 Handle authorize and forbid for redirecting handlers. --- samples/OpenIdConnectSample/Startup.cs | 46 ++++++++++++++++--- .../Properties/launchSettings.json | 4 +- samples/SocialSample/Startup.cs | 29 ++++++++---- .../RemoteAuthenticationHandler.cs | 33 +++++++++++-- 4 files changed, 91 insertions(+), 21 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index c2f831e19..3fffe9ce6 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -6,6 +6,7 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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.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($""); + 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; + } - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + // Authenticated, but not authorized + if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + 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 903a81588..9224a4881 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 f8c7495d3..4f3a03d50 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -313,21 +313,32 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) }); }); - // Deny anonymous request beyond this point. - app.Use(async (context, next) => + + app.Run(async context => { - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + // 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; } - await next(); - }); - // Display user information - app.Run(async context => - { + // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 d6cc4ce7f..f1ad0d055 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -89,9 +89,32 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 @@ protected override Task HandleSignInAsync(SignInContext context) 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 184/611] #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 380e6f937..c7bff38d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs @@ -5,7 +5,6 @@ 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 @@ public ChunkingCookieManager(UrlEncoder urlEncoder) /// 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 @@ private static int ParseChunksCount(string value) /// /// 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 @@ public string GetRequestCookie(HttpContext context, string key) 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 @@ public string GetRequestCookie(HttpContext context, string key) // 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 @@ public string GetRequestCookie(HttpContext context, string key) /// /// 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 @@ public void AppendResponseCookie(HttpContext context, string key, string value, 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 @@ public void AppendResponseCookie(HttpContext context, string key, string value, 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 @@ public void AppendResponseCookie(HttpContext context, string key, string value, { // 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) { 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) }); } } - - 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 ff54957cf..14d152a81 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs @@ -42,7 +42,7 @@ public CookieAuthenticationMiddleware( } 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 000000000..b323258d9 --- /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 000000000..1e75761b7 --- /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 4b92f08c8..670baf5db 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 @@ public void AppendLargeCookie_Appended() 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 @@ public void AppendLargeCookieWithLimit_Chunked() 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 @@ public void AppendLargeCookieWithLimit_Chunked() }, 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 @@ public void GetLargeChunkedCookie_Reassembled() "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 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingEnabled_Throws() "TestCookieC7=STUVWXYZ" }; - Assert.Throws(() => new ChunkingCookieManager(null).GetRequestCookie(context, "TestCookie")); + Assert.Throws(() => new ChunkingCookieManager().GetRequestCookie(context, "TestCookie")); } [Fact] @@ -134,7 +90,7 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingDisabled_NotReassemble 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 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingDisabled_NotReassemble "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 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingDisabled_NotReassemble 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 f08d7fef8..34d967617 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 @@ public async Task CookiePolicyCallsCookieFeature() 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 6e64aba57..26cc946be 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 2abb115e4..79288b026 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.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 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() .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 @@ public async Task InteropWithNewCookieContainsIdentity() }); }); - 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 @@ private static string FindClaimValue(Transaction transaction, string claimType) 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 @@ private static void Describe(IOwinResponse res, Owin.Security.AuthenticateResult } } - 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 @@ private static async Task SendAsync(TestServer server, string uri, }; 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 @@ private class Transaction 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 185/611] 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 06de08d84..e5107da8f 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 186/611] Fix OSX build on Travis. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index df22f7a88..ceb3c7b67 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 187/611] #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 a81f11dfb..fe77dd1a7 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 @@ public static class Program { 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 @@ public static void Main(string[] args) 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 557b6921e..48610115f 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 3fffe9ce6..6beaa0a20 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -78,6 +78,14 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } 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 5f0744e0b..32e19ca40 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 386819e6f..f3cad66ad 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -11,8 +11,6 @@ public static class Program { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel(options => { @@ -20,7 +18,6 @@ public static void Main(string[] args) 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 57600cee8..128fa08a3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs @@ -35,6 +35,11 @@ public interface IOpenIdConnectEvents : IRemoteAuthenticationEvents ///
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 9893b7207..42d35b798 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -36,6 +36,11 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve /// 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 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve 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 000000000..b5077e035 --- /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 ff580ff26..ef1d5d83b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -47,6 +47,9 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ public static void PostAuthenticationLocalRedirect(this ILogger logger, string r { _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 f85ba9c14..e23173ed1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -62,6 +62,33 @@ public OpenIdConnectHandler(HttpClient backchannel, HtmlEncoder htmlEncoder) 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 cdbc9e0f0..c9b614acd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -50,6 +50,7 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 188/611] 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 f174174cf..54989c13a 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,43 +12,82 @@ public class AuthPropertiesTokenCache : TokenCache { 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); + } + private void AfterAccessNotificationWithProperties(TokenCacheNotificationArgs args) + { + // if state changed + if (HasStateChanged) + { + var cachedTokens = Serialize(); + var cachedTokensText = Convert.ToBase64String(cachedTokens); + _authProperties.Items[TokenCacheKey] = cachedTokensText; + } } - // 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 AfterAccessNotificationWithContext(TokenCacheNotificationArgs args) { // if state changed if (HasStateChanged) { - HasCacheChanged = true; + AfterAccessNotificationWithProperties(args); + var cachedTokens = Serialize(); var cachedTokensText = Convert.ToBase64String(cachedTokens); _authProperties.Items[TokenCacheKey] = cachedTokensText; + _httpContext.Authentication.SignInAsync(_signInScheme, _principal, _authProperties).Wait(); } } diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 5dcda4c86..254668022 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -8,11 +8,8 @@ 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() diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json index 2ae08a6cc..62dc4ef77 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 f4d0c37aa..37a49b7ab 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -89,12 +89,12 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 40308478b..04cc2d01e 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 189/611] 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 cd8aab3ae..df74352e7 100644 --- a/samples/CookieSample/Program.cs +++ b/samples/CookieSample/Program.cs @@ -8,11 +8,8 @@ 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() diff --git a/samples/CookieSample/Properties/launchSettings.json b/samples/CookieSample/Properties/launchSettings.json index 75da70bee..afe862f4f 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 6b9014f5e..adf8f1f1a 100644 --- a/samples/CookieSessionSample/Program.cs +++ b/samples/CookieSessionSample/Program.cs @@ -8,11 +8,8 @@ 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() diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/samples/CookieSessionSample/Properties/launchSettings.json index 15b478a0e..edb6e4dd1 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 82da93d59..44d2fe0c4 100644 --- a/samples/JwtBearerSample/Program.cs +++ b/samples/JwtBearerSample/Program.cs @@ -8,11 +8,8 @@ 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() diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/samples/JwtBearerSample/Properties/launchSettings.json index f5dfcd018..e89788c48 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 9224a4881..251bfbffd 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 190/611] #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 3a8365a5b..eecd03065 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -192,7 +192,7 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 191/611] 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 97aa5b381..171fe014d 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 @@ public static AuthorizationPolicy Combine(IEnumerable polic 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 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera 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 @@ public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumera } 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 97b806e87..e053e41f9 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -22,7 +22,12 @@ public DefaultAuthorizationPolicyProvider(IOptions options } _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 1a0dbace6..ac141b327 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -16,5 +16,11 @@ public interface IAuthorizationPolicyProvider /// /// 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 f74e46152..6825dd868 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 @@ public void RequireRoleThrowsIfEmpty() } [Fact] - public void CanCombineAuthorizeAttributes() + public async Task CanCombineAuthorizeAttributes() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -31,8 +33,10 @@ public void CanCombineAuthorizeAttributes() 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 @@ public void CanCombineAuthorizeAttributes() } [Fact] - public void CanReplaceDefaultPolicy() + public async Task CanReplaceDefaultPolicy() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -56,8 +60,10 @@ public void CanReplaceDefaultPolicy() 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 @@ public void CanReplaceDefaultPolicy() } [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 @@ public void CombineMustTrimRoles() } [Fact] - public void CombineMustTrimAuthenticationScheme() + public async Task CombineMustTrimAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -97,8 +104,10 @@ public void CombineMustTrimAuthenticationScheme() }; 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 @@ public void CombineMustTrimAuthenticationScheme() } [Fact] - public void CombineMustIgnoreEmptyAuthenticationScheme() + public async Task CombineMustIgnoreEmptyAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -115,8 +124,10 @@ public void CombineMustIgnoreEmptyAuthenticationScheme() }; 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 @@ public void CombineMustIgnoreEmptyAuthenticationScheme() } [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 42948c936..b6383ffb4 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -8,6 +8,7 @@ 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 @@ private IAuthorizationService BuildAuthorizationService(Action(() => 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 @@ public async Task CanAuthorizeWithAsyncAssertionRequirement() 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 @@ public async Task CanReplaceDefaultPolicyProvider() 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 192/611] 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 37a49b7ab..2fc8ac19b 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services) 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 04cc2d01e..7727c0ba3 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 193/611] #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 b3a4d21ba..b4dcf1147 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 @@ public JwtBearerChallengeContext(HttpContext context, JwtBearerOptions options, } 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 40a0b2efd..077f1debd 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -5,6 +5,7 @@ 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con } 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 e23173ed1..c674e2107 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -575,7 +575,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 81c03dc83..5a10ef616 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 @@ public async Task BearerTokenValidation() { 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 @@ public async Task BearerTokenValidation() [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 @@ public async Task SignInThrows() [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 @@ public async Task CustomHeaderReceived() { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -117,10 +110,7 @@ public async Task HeaderWithoutBearerReceived() [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 @@ public async Task UnrecognizedTokenReceived() [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 @@ public async Task CustomTokenValidated() { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -185,7 +225,6 @@ public async Task RetrievingTokenFromAlternateLocation() { var options = new JwtBearerOptions() { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -233,7 +272,6 @@ public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -266,7 +304,6 @@ public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -298,7 +335,6 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -330,8 +366,6 @@ public async Task EventOnChallengeSkipped_ResponseNotModified() { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, - AutomaticChallenge = true, Events = new JwtBearerEvents() { OnChallenge = context => @@ -352,8 +386,16 @@ class InvalidTokenValidator : ISecurityTokenValidator { 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 @@ public int MaximumTokenSizeInBytes 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 194/611] 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 | 77 +++++++++++++++---- .../OpenIdConnectMiddleware.cs | 4 + 6 files changed, 98 insertions(+), 17 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 6beaa0a20..e9836506a 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -6,7 +6,6 @@ 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 32e19ca40..c507160fe 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 b5077e035..a76dc9e59 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 ef1d5d83b..d0f3e12d9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -50,6 +50,8 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ public static void RemoteSignOut(this ILogger logger) { _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 c674e2107..a10122b7a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -66,27 +66,74 @@ public override async Task HandleRequestAsync() { if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) { - var remoteSignOutContext = new RemoteSignOutContext(Context, Options); - await Options.Events.RemoteSignOut(remoteSignOutContext); + 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))); + } - if (remoteSignOutContext.HandledResponse) + 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.RemoteSignOutHandledResponse(); + Logger.RemoteSignOutSessionIdMissing(); return true; } - if (remoteSignOutContext.Skipped) + // Ensure the 'sid' parameter corresponds to the 'sid' stored in the authentication ticket. + if (!string.Equals(sid, message.GetParameter("sid"), StringComparison.Ordinal)) { - Logger.RemoteSignOutSkipped(); - return false; + Logger.RemoteSignOutSessionIdInvalid(); + return true; } + } - Logger.RemoteSignOut(); + Logger.RemoteSignOut(); - // We've received a remote sign-out request - await Context.Authentication.SignOutAsync(Options.SignOutScheme ?? Options.SignInScheme); - return true; - } - return await base.HandleRequestAsync(); + // We've received a remote sign-out request + await Context.Authentication.SignOutAsync(Options.SignOutScheme); + return true; } /// @@ -132,7 +179,9 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 b08f8e944..8d880d0d9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -100,6 +100,10 @@ public OpenIdConnectMiddleware( { 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 195/611] 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 f32798072..ab822bd68 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 196/611] 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 f6877f114..2eb19c617 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -6,65 +6,63 @@ 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); - } - } - } - - 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); + await HandleRequirementAsync(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 cf7896a30..afe9e43f0 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs @@ -5,8 +5,15 @@ 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 644b33086..c5a06c2f9 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 @@ public ClaimsAuthorizationRequirement(string claimType, IEnumerable allo 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 @@ protected override void Handle(AuthorizationHandlerContext context, ClaimsAuthor 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 57ad22dff..82d40639b 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 @@ protected override void Handle(AuthorizationHandlerContext context, DenyAnonymou { 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 b0c4e6b10..3643b1fb7 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 @@ public NameAuthorizationRequirement(string requiredName) 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 @@ protected override void Handle(AuthorizationHandlerContext context, NameAuthoriz 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 a57a0e4c8..53d6beb16 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 @@ public RolesAuthorizationRequirement(IEnumerable allowedRoles) 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 @@ protected override void Handle(AuthorizationHandlerContext context, RolesAuthori 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 b6383ffb4..19bd761e0 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -584,9 +584,10 @@ public async Task CanBlockNonAuthenticatedUser() 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 @@ public PassThroughRequirement(bool succeed) 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 @@ public ExpenseReportAuthorizationHandler(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 @@ public async Task CanAuthorizeAllSuperuserOperations() 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 @@ protected override void Handle(AuthorizationHandlerContext context, OperationAut 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 197/611] 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 b4dcf1147..584681253 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -22,5 +22,25 @@ public JwtBearerChallengeContext(HttpContext context, JwtBearerOptions options, /// 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 077f1debd..34b13562a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -191,6 +191,14 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con { 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con // 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 837928e77..1d73b843e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -118,5 +118,12 @@ public JwtBearerOptions() : base() /// 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 5a10ef616..b1f0ce4fe 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.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 @@ public async Task InvalidTokenReceived() 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 @@ public async Task ExceptionNotReportedInHeaderForOtherFailures(Type errorType) 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 @@ public async Task ExceptionsReportedInHeaderForMultipleAuthenticationFailures() 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 198/611] 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 2fc8ac19b..40727ff1a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -80,7 +80,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 e9836506a..3a3991903 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -72,7 +72,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 a10122b7a..4189ee262 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -286,8 +286,8 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con // 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 c9b614acd..b5f6c03da 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -38,8 +38,8 @@ public OpenIdConnectOptions() /// Caption: . /// ProtocolValidator: new . /// RefreshOnIssuerKeyNotFound: true - /// ResponseType: - /// Scope: . + /// ResponseType: + /// Scope: . /// TokenValidationParameters: new with AuthenticationScheme = authenticationScheme. /// UseTokenLifetime: false. /// @@ -144,12 +144,12 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 66fc2f4ba..98df02ee6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs @@ -25,8 +25,8 @@ public ExpectedQueryValues(string authority, OpenIdConnectConfiguration configur 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 @@ public void CheckValues(string query, IEnumerable parameters) 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 @@ public string ExpectedAuthority { 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 20de13571..41154820b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -113,7 +113,7 @@ public async Task ChallengeSettingMessage() 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 @@ public async Task SignOutSettingMessage() 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 199/611] 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 40727ff1a..f27a52492 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -87,7 +87,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 200/611] 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 613cadae3..af3f17a99 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 63464eab9..178947525 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 201/611] 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 954c36643..aa38029d9 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 a3626218c..fb8d16c02 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 a82778a76..5bf0a928a 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 7727c0ba3..ff03a5584 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 c507160fe..7e0aa0e5f 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 fb19d3ec2..98ff9263a 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 27b5f34ea..35fedfada 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 3051e5fa7..37d91ba54 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 f0c04896e..2863967e2 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 3a7b5e03e..81f34b736 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 af3f17a99..971a8d696 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 11d887e5c..b80faf063 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 178947525..7d830ad8c 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 e5107da8f..dc56181a7 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 202/611] 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 2eb19c617..a4a923c3c 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -16,7 +16,7 @@ public abstract class AuthorizationHandler : IAuthorizationHandler /// /// 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 @@ public virtual async Task HandleAsync(AuthorizationHandlerContext context) /// /// 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 @@ public abstract class AuthorizationHandler : IAuthoriza /// /// 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 @@ public virtual async Task HandleAsync(AuthorizationHandlerContext context) /// /// 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 2349feb31..65aafa2bb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -17,6 +17,12 @@ public class AuthorizationHandlerContext 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 @@ public AuthorizationHandlerContext( _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 @@ public bool HasSucceeded } } + /// + /// 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 94799af29..5031c68b9 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -14,8 +14,11 @@ public class AuthorizationOptions 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 171fe014d..41eb7aade 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -8,8 +8,23 @@ 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 @@ public AuthorizationPolicy(IEnumerable requirements, 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 @@ public static AuthorizationPolicy Combine(params AuthorizationPolicy[] policies) 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 @@ public static AuthorizationPolicy Combine(IEnumerable polic 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 653727f5e..37335df8f 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -9,21 +9,47 @@ 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 @@ public AuthorizationPolicyBuilder AddAuthenticationSchemes(params string[] schem 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 @@ public AuthorizationPolicyBuilder AddRequirements(params IAuthorizationRequireme 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 @@ public AuthorizationPolicyBuilder Combine(AuthorizationPolicy policy) 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 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] 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 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable + /// 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 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType) 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 @@ public AuthorizationPolicyBuilder RequireRole(params string[] roles) 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 @@ public AuthorizationPolicyBuilder RequireRole(IEnumerable roles) 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 @@ public AuthorizationPolicyBuilder RequireUserName(string userName) 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 @@ public AuthorizationPolicyBuilder RequireAuthenticatedUser() } /// - /// 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 8979c5c63..197e89cf8 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -8,16 +8,22 @@ 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai } /// - /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai } /// - /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai } /// - /// 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 cdfab44f1..c911dc56b 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -29,7 +29,6 @@ public AuthorizeAttribute(string policy) 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 e053e41f9..2c9ea19b5 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -8,12 +8,17 @@ 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 @@ public DefaultAuthorizationPolicyProvider(IOptions options _options = options.Value; } + /// + /// Gets the default authorization policy. + /// + /// The default authorization policy. public Task GetDefaultPolicyAsync() { return Task.FromResult(_options.DefaultPolicy); @@ -32,8 +41,8 @@ public Task GetDefaultPolicyAsync() /// /// 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 d90cf1803..4ac87eff4 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -11,12 +11,21 @@ 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, _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 @@ private static string GetClaimValue(IIdentity identity, string claimsType) 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 7593e0ad3..8531c3daa 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 ac141b327..9e9d0f468 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -13,14 +13,14 @@ public interface IAuthorizationPolicyProvider /// /// 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 800789a8c..0bdcaff86 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 e3b9fec91..369e3b576 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -15,10 +15,13 @@ public interface IAuthorizationService /// /// 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 @@ public interface IAuthorizationService /// 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 3371134b4..b48449b5c 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -14,10 +14,13 @@ public interface IAuthorizeData 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 2ddf06526..1c38b800e 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -6,33 +6,49 @@ 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 c5a06c2f9..0e28ba077 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -8,10 +8,19 @@ 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 @@ public ClaimsAuthorizationRequirement(string claimType, IEnumerable allo 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 82d40639b..7f2671775 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -6,8 +6,17 @@ 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 3643b1fb7..aca1920d7 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -8,10 +8,15 @@ 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 @@ public NameAuthorizationRequirement(string requiredName) 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 455d66ff2..c3f16356d 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 d718591ec..60fd66b85 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -6,8 +6,16 @@ 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 53d6beb16..6e5aa7224 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -8,10 +8,16 @@ 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 @@ public RolesAuthorizationRequirement(IEnumerable allowedRoles) 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 203/611] 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 65aafa2bb..5dc57c278 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -55,7 +55,7 @@ public AuthorizationHandlerContext( 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 5031c68b9..fa9e9ef1e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -14,7 +14,7 @@ public class AuthorizationOptions 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 41eb7aade..3fe0cdd07 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -52,7 +52,7 @@ public AuthorizationPolicy(IEnumerable requirements, 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 @@ public static AuthorizationPolicy Combine(IEnumerable polic /// /// 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 197e89cf8..3b78c952e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -22,7 +22,7 @@ public static class AuthorizationServiceExtensions /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 4ac87eff4..6665204ee 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -24,7 +24,7 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, } /// - /// 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 @@ private static string GetClaimValue(IIdentity identity, string claimsType) } /// - /// 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 1c38b800e..5fa452b73 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 204/611] 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 369e3b576..a130c84b0 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -16,24 +16,39 @@ public interface IAuthorizationService /// 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 205/611] 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 aa38029d9..00dafe618 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 fb8d16c02..20f7899d4 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 5bf0a928a..5296a40fb 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 ff03a5584..33fcb0a43 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 7e0aa0e5f..0069f3024 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 98ff9263a..5d61d71c4 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 01d03d2b3..57d98ac8e 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 11b3caf4d..075daedfb 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 26cc946be..0027c57e6 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 4dac4d3a2..d728848e5 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 206/611] 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 5500f6d50..71b9724a0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691..cf8bff13b 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 f4208100e..f88fe4052 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 207/611] 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 971a8d696..c302892a3 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 7d830ad8c..a1a7ba5e1 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 208/611] 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 00dafe618..57ceb354a 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 20f7899d4..6530e1cf0 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 5296a40fb..21d2365ec 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 33fcb0a43..adb6a845a 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 0069f3024..6a24f3da6 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 5d61d71c4..227354e51 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 c98a4bba1..7ddff7ce8 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 35fedfada..796b3bf7c 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 37d91ba54..dde8c3a54 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 2863967e2..2f8ea6072 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 81f34b736..3169adf72 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 c302892a3..192801ced 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 b80faf063..5243a96a7 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 a1a7ba5e1..8696821dd 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 dc56181a7..460549c7b 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 0f9becfc8..8e72b62f8 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 3cd40fd20..4cf5f4881 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 f94978e52..c7b3326a0 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 57d98ac8e..2536d1425 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 075daedfb..adffd1e58 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 0027c57e6..2fc65d73d 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 d728848e5..3178f9bbe 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 209/611] 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 4189ee262..6488d10d7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -112,17 +112,19 @@ protected virtual async Task HandleRemoteSignOutAsync() // 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 210/611] 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 2536d1425..0feac5dd9 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 adffd1e58..f8fda41e3 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 2fc65d73d..89673d848 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 3178f9bbe..e622bd746 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 211/611] 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 bb23e6481..f6575c3e0 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 c81393af1..1c347c845 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 ed0c9b32b..97f5837ce 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 e3495a211..26e9f9030 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 905bce8e3..9029ad0f1 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 775eebbc2..b439f74d1 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 8c4f3cd41..238c0cec6 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 395259212..caa72075e 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 ff412f08a..ab6048872 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 8d87a04b7..738458398 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 52dd6cb67..a4ccc9863 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 34a397bd5..20b825dca 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 2f970b513..6a07e8120 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 5fba7a974..b72a631fa 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 e03db0847..b3345c6cf 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 c6a57567b..cc6041f8f 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 5ffad968d..0cd49f324 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 c6b01504a..052e99816 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 aec10ee93..1050a47ad 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 d596a5bb4..59bcbc9c4 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 cf42659a0..06582d576 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 96d5b6c5a..d7f7c9d95 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 212/611] 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 254668022..11d1fbeaf 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 000000000..37dda75a7 --- /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 f27a52492..8a2b7f441 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -7,7 +7,6 @@ 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 adb6a845a..6aee5073f 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 213/611] 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 fe77dd1a7..b370c85a9 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -17,6 +17,7 @@ public static void Main(string[] args) 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 000000000..293820759 --- /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 3a3991903..32d4739d1 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -86,6 +86,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) await context.Response.WriteAsync($""); return; } + if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -95,6 +96,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) await context.Response.WriteAsync($""); return; } + if (context.Request.Path.Equals("/signout-remote")) { // Redirects @@ -105,6 +107,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) }); 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 6a24f3da6..a6a16a29f 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 214/611] 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 df74352e7..7deed359e 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 80a6f949a..b11dec93f 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 29dd7c67e..a6cf91046 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 bf30cae9e..8b168c9a0 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 0e757e42a..8752c3b73 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 215/611] 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 8752c3b73..000000000 --- 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 216/611] 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 f9455f23a..b42561250 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -138,12 +138,6 @@ public string CookieName /// 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 1d73b843e..2aedf30d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -95,12 +95,6 @@ public JwtBearerOptions() : base() /// 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 ddd26d9f0..12b85ae7e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -175,10 +175,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 57ecba2f4..9591d9c44 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -64,11 +64,5 @@ public OAuthOptions() /// 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 6488d10d7..df7caf331 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -259,10 +259,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con // 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 b5f6c03da..181444b05 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -202,11 +202,5 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 4fbf35aaa..20d06beaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -131,10 +131,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 8ab399a8f..bf54b7fbb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -59,11 +59,5 @@ public TwitterOptions() 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 04d050b06..34ec577f1 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 @@ public string AuthenticationScheme /// 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 f1ad0d055..72a4fe590 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -149,7 +149,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties { 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 217/611] 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 293820759..846e3f8e6 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 218/611] 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 3fe0cdd07..5cba0fd9e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -122,28 +122,28 @@ public static async Task CombineAsync(IAuthorizationPolicyP 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 2c9ea19b5..6fb8bd68d 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -45,6 +45,7 @@ public Task GetDefaultPolicyAsync() /// 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 219/611] 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 a78c14bbe..e990abd05 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 @@ public class RemoteAuthenticationOptions : AuthenticationOptions 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 @@ public string DisplayName /// 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 220/611] 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 fe693a61b..85a193d82 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 @@ public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuild } /// - /// 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 @@ public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuild { 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 c17ff6b2a..ef6fae9bc 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 affde917a..6e3ee3693 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -22,7 +22,10 @@ public GoogleHandler(HttpClient httpClient) { } - 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties, 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 0a763d569..336536c51 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 eb98e447b..5f8afaff2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -69,7 +69,10 @@ public GoogleMiddleware( /// /// 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 221/611] 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 ef6fae9bc..77d68aed9 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 222/611] 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 675ae5149..0df42597d 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 @@ protected override async Task CreateTicketAsync(ClaimsIden } 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 @@ protected override async Task CreateTicketAsync(ClaimsIden { 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 6e3ee3693..4a81744b0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -32,7 +32,11 @@ protected override async Task CreateTicketAsync( 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 8b9177625..18f5df9d4 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 12b85ae7e..29d46367d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -119,7 +119,15 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 223/611] 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 72a4fe590..5891a005d 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -87,6 +87,12 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 224/611] 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 0df42597d..4deec4df7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,8 +38,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 4a81744b0..b9a24f58c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,8 +34,7 @@ protected override async Task CreateTicketAsync( 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 18f5df9d4..ad4ceb81f 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,8 +28,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 29d46367d..353b2b584 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.Features.Authentication; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; +using System.Threading; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -119,14 +120,14 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 5891a005d..f152ff1cf 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -9,6 +9,7 @@ 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 @@ public override async Task HandleRequestAsync() 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."); + } + } + catch (Exception ex) + { + exception = ex; } - if (authResult == null || !authResult.Succeeded) + + if (exception != null) { - var errorContext = new FailureContext(Context, authResult?.Failure ?? new Exception("Invalid return state, unable to redirect.")); - Logger.RemoteAuthenticationError(errorContext.Failure.Message); + 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 225/611] 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 f152ff1cf..b1e2aa1c8 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -114,8 +114,7 @@ protected virtual async Task HandleRemoteCallbackAsync() /// /// 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 226/611] 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 b1e2aa1c8..895a954da 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -112,9 +112,9 @@ protected virtual async Task HandleRemoteCallbackAsync() } /// - /// 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 227/611] 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 353b2b584..b235d9358 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.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.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 895a954da..564064e40 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.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 228/611] 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 564064e40..65ad981a9 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -44,12 +44,12 @@ protected virtual async Task HandleRemoteCallbackAsync() } 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 229/611] 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 b235d9358..dbfa1ef92 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.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 65ad981a9..452a15a9d 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 @@ public override async Task HandleRequestAsync() 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 @@ protected virtual async Task HandleRemoteCallbackAsync() exception = authResult?.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); } + + ticket = authResult.Ticket; } catch (Exception ex) { @@ -67,18 +69,16 @@ protected virtual async Task HandleRemoteCallbackAsync() { 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 230/611] 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 4deec4df7..29906e7e3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 452a15a9d..9d236decd 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -37,7 +37,7 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 231/611] 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 b9a24f58c..68cc6054f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,7 +34,7 @@ protected override async Task CreateTicketAsync( 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 @@ private static void AddQueryString( 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 ad4ceb81f..21f567d15 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,7 +28,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 232/611] 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 9d236decd..4dfcc3662 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -37,18 +37,17 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 233/611] 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 6fb8bd68d..0e4329dcc 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -45,7 +45,9 @@ public Task GetDefaultPolicyAsync() /// 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 234/611] 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 8065139ba..9f5c96cc1 100644 --- a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs @@ -63,6 +63,26 @@ public static string GetTokenValue(this AuthenticationProperties properties, str : 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 235/611] 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 e8f2c1657..028cf6760 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -81,6 +81,51 @@ public void CanUpdateTokens() 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 236/611] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ceb3c7b67..efc1a5721 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 237/611] 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 29906e7e3..be1c8f8f8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 @@ protected override string FormatScope() 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 238/611] 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 eecd03065..302010429 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -323,7 +323,6 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr 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 34b13562a..ee5575251 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -185,11 +185,11 @@ protected override async Task HandleAuthenticateAsync() 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 639be0103..9141e8811 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -233,15 +233,43 @@ public async Task AuthenticateAsync(AuthenticateContext context) } } + /// + /// 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 @@ public async Task ChallengeAsync(ChallengeContext context) { 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 @@ private void UnregisterAuthenticationHandler() 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 b1f0ce4fe..fea01b36f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -59,6 +59,46 @@ public async Task SignOutThrows() 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 @@ public async Task NoHeaderReceived() 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 @@ public async Task BearerTurns401To403IfAuthenticated() 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 @@ public BlobTokenValidator(string authenticationScheme, Action tokenValid public string AuthenticationScheme { get; } public bool CanValidateToken => true; - + public int MaximumTokenSizeInBytes { get @@ -558,11 +598,21 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame } } - 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 @@ private static TestServer CreateServer(JwtBearerOptions options, Func 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 239/611] 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 9141e8811..d0528186c 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -255,18 +255,15 @@ protected Task HandleAuthenticateOnceAsync() /// 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 240/611] 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 302010429..9a26667ac 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -165,7 +165,7 @@ protected override async Task FinishResponseAsync() } // 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 241/611] 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 9a26667ac..b147181af 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -164,7 +164,6 @@ protected override async Task FinishResponseAsync() 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 d0528186c..1e642d82d 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -234,9 +234,8 @@ public async Task AuthenticateAsync(AuthenticateContext context) } /// - /// 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 @@ protected Task HandleAuthenticateOnceAsync() } /// - /// 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 242/611] 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 5500f6d50..0fd623ffd 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 243/611] 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 b147181af..528e11c85 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -311,14 +311,24 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr 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 244/611] 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 fa4a4502f..a5283c80f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -90,7 +90,6 @@ public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() Assert.True(responded.Single().StartsWith("http://example.com/Account/Login")); } - [Theory] [InlineData(true)] [InlineData(false)] @@ -1052,6 +1051,53 @@ public async Task NestedMapWillNotAffectLogin() 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 245/611] 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 528e11c85..e9eff38ac 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -315,20 +315,23 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { CookieRedirectContext redirectContext = null; - - var query = Request.Query; - var redirectUri = query[Options.ReturnUrlParameter]; - if (!StringValues.IsNullOrEmpty(redirectUri) && IsHostRelative(redirectUri)) - { - redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); - } - else if (!string.IsNullOrEmpty(properties.RedirectUri) && IsHostRelative(properties.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, 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 a5283c80f..9fc36e6d9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1074,6 +1074,29 @@ await context.Authentication.SignInAsync( 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 @@ await context.Authentication.SignInAsync( 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 246/611] 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 e9eff38ac..ff77815ce 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -320,7 +320,7 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr // 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 9fc36e6d9..4a4d19a02 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1051,8 +1051,10 @@ public async Task NestedMapWillNotAffectLogin() 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 @@ public async Task RedirectUriIsHoneredAfterSignin() 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 @@ await context.Authentication.SignInAsync( 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 247/611] 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 ff77815ce..9b4573875 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.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 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { - CookieRedirectContext redirectContext = null; - // set redirect uri in order: // 1. properties.RedirectUri // 2. query parameter ReturnUrlParameter @@ -331,8 +328,8 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr 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 4a4d19a02..942b1c4a5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1100,7 +1100,7 @@ await context.Authentication.SignInAsync( } [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 248/611] 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 9b4573875..f11f69e1c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -316,6 +316,9 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr // 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 249/611] 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 000000000..de921bb96 --- /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 000000000..4ada6ff85 --- /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 41154820b..5853e3896 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.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 @@ public class OpenIdConnectMiddlewareTests 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 @@ public async Task ChallengeWillIssueHtmlFormWhenEnabled() { var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost @@ -59,7 +59,7 @@ public async Task ChallengeWillIssueHtmlFormWhenEnabled() 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 @@ public async Task ChallengeWillSetNonceAndStateCookies() { var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = TestUtilities.DefaultOpenIdConnectConfiguration }); @@ -91,7 +91,7 @@ public async Task ChallengeWillSetNonceAndStateCookies() [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 @@ public async Task ChallengeSettingMessage() 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 @@ public async Task SignOutSettingMessage() EndSessionEndpoint = ExpectedLogoutRequest }; - var queryValues = new ExpectedQueryValues(DefaultAuthority, configuration) + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority, configuration) { RequestType = OpenIdConnectRequestType.Logout }; @@ -198,7 +198,7 @@ public override string CreateLogoutRequestUrl() [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 @@ public static TheoryData StateDataSet [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 @@ private OpenIdConnectOptions GetOptions(List parameters, ExpectedQueryVa 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 @@ public async Task SignOutWithDefaultRedirectUri() var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = configuration }); @@ -349,7 +351,7 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 @@ private static DateTime GetNonceExpirationTime(string keyname, TimeSpan nonceLif 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 250/611] 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 c92be6232..f56ea5c19 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -27,6 +27,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic 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 000000000..64cc695b8 --- /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 6665204ee..45ee4aa4a 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, { 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 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 000000000..7b2c5d1bc --- /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 19bd761e0..749a11dc3 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1019,5 +1019,30 @@ public async Task CanUseDynamicPolicyProvider() 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 251/611] 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 5dc57c278..b6378e407 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -42,32 +42,32 @@ public AuthorizationHandlerContext( /// /// 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 @@ public bool HasSucceeded /// 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 @@ public void Fail() /// 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 f56ea5c19..a9961b69e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -28,6 +28,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic 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 000000000..2dae5e5e7 --- /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 45ee4aa4a..89777eab0 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, { 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, _policyProvider = policyProvider; _logger = logger; _evaluator = evaluator; + _contextFactory = contextFactory; } /// @@ -78,7 +85,7 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 000000000..272109eea --- /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 749a11dc3..7f9e5642a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1038,11 +1038,52 @@ 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")); } + + + 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 252/611] Refine OIDC sample 1. Add signout remote scenario 2. Use bootstrap to enhance the view 3. Improve readability --- .../OpenIdConnect.AzureAdSample/Startup.cs | 105 +++++++++++++----- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 8a2b7f441..f0c2f7c22 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,46 +105,89 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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}"); + 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 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}"); + } + }); } - catch (Exception ex) + }); + } + + 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 context.Response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); + await response.WriteAsync($""); } - - await context.Response.WriteAsync("Sign Out"); - await context.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 253/611] 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 f0c2f7c22..45304e1bd 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ await WriteHtmlAsync(context.Response, { 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 @@ await WriteHtmlAsync(context.Response, 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 @@ await WriteHtmlAsync(context.Response, async response => } catch (Exception ex) { - await response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); + await response.WriteAsync($"AquireToken error: {ex.Message}"); } }); } @@ -189,6 +190,9 @@ private static async Task WriteTableHeader(HttpResponse response, IEnumerable"); } + + 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 254/611] 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 45304e1bd..0645b995e 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -107,7 +107,11 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ await WriteHtmlAsync(context.Response, { 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 255/611] 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 0645b995e..fcfc7b4df 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -157,7 +157,7 @@ await WriteHtmlAsync(context.Response, async response => 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 @@ private static async Task WriteTableHeader(HttpResponse response, IEnumerable"); 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 @@ private static async Task WriteTableHeader(HttpResponse response, IEnumerable"); 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 256/611] 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 1be4b80bc..000000000 --- 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 98df02ee6..000000000 --- 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 de921bb96..000000000 --- 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 000000000..432980f77 --- /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 000000000..b2e2514d6 --- /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 4ada6ff85..3603c2bf4 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 5853e3896..4a750ea41 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 @@ public class OpenIdConnectMiddlewareTests { 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 - { - 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) => - { - 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() + var setting = new TestSettings(opt => { - OnRedirectToIdentityProvider = context => + opt.Configuration = new OpenIdConnectConfiguration { - 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 @@ public async Task SignOutWithDefaultRedirectUri() [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 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWithCustomRedirectUri() [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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 000000000..c3e92a904 --- /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 000000000..f8ab6fdb0 --- /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 000000000..47605dcce --- /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 000000000..3bbd3152b --- /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 6247c85b4..000000000 --- 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 257/611] 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 b2e2514d6..bf0d9ff0e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -89,7 +89,7 @@ public async Task ChallengeCanSetUserStateThroughProperties(string userState) 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 @@ public async Task ChallengeSetsNonceAndStateCookies() 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 3603c2bf4..0f5338c5c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -17,7 +17,7 @@ public void MetadataAddressIsGeneratedFromAuthorityWhenMissing() { var options = new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = Guid.NewGuid().ToString(), SignInScheme = Guid.NewGuid().ToString() }; @@ -32,7 +32,7 @@ public void ThrowsWhenSignInSchemeIsMissing() TestConfigurationException( new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = Guid.NewGuid().ToString() }, ex => Assert.Equal("SignInScheme", ex.ParamName)); @@ -45,7 +45,7 @@ public void ThrowsWhenClientIdIsMissing() 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 4a750ea41..f2ea92292 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -48,10 +48,10 @@ public async Task SignOutSettingMessage() [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 @@ public async Task SignOutWithDefaultRedirectUri() [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 @@ public async Task SignOutWithCustomRedirectUri() [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 c3e92a904..000000000 --- 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 f8ab6fdb0..5a672093e 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.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 @@ await context.Authentication.SignOutAsync( 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 47605dcce..3e50a7abe 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -28,7 +28,7 @@ public TestSettings() : this(configure: null) public TestSettings(Action configure) { - _options = TestDefaultValues.CreateOpenIdConnectOptions(configure); + _options = TestServerBuilder.CreateOpenIdConnectOptions(configure); } public TestSettings(OpenIdConnectOptions options) @@ -193,7 +193,7 @@ private void ValidateScope(IDictionary actualQuery, ICollection< 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 258/611] 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 bf0d9ff0e..78f84c04f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -21,7 +21,7 @@ public async Task ChallengeIsIssuedCorrectly() 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 @@ public async Task ChallengeIssueedCorrectlyForFormPost() 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 @@ public async Task ChallengeCanSetUserStateThroughProperties(string userState) 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 @@ public async Task OnRedirectToIdentityProviderEventCanSetState(string userState) }); 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 @@ public async Task OnRedirectToIdentityProviderEventIsHit() ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); Assert.True(eventIsHit); @@ -198,7 +198,7 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceValues() ); 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 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceMessage() ); 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 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() ); 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 @@ public async Task OnRedirectToIdentityProviderEventSkipResponse() ); 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 @@ public async Task ChallengeSetsNonceAndStateCookies() { 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 f2ea92292..959d64ace 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -36,7 +36,7 @@ public async Task SignOutSettingMessage() 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 @@ public async Task SignOutWithDefaultRedirectUri() 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 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 000000000..a7085966a --- /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 3bbd3152b..745c41350 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 259/611] 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 78f84c04f..fc9338e2b 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 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() { OnRedirectToIdentityProvider = context => { + context.Response.StatusCode = 410; + context.Response.Headers.Add("tea", "Oolong"); context.HandleResponse(); + return Task.FromResult(0); } }; @@ -270,7 +275,8 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() 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 @@ public async Task ChallengeSetsNonceAndStateCookies() 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 260/611] 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 b370c85a9..49cbf139d 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -13,7 +13,7 @@ public static void Main(string[] args) 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 32d4739d1..37b753102 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 261/611] 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 fcfc7b4df..05c073b46 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 262/611] 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 | 216 +++++++++++------- .../OpenIdConnectOptions.cs | 12 +- .../RemoteAuthenticationHandler.cs | 1 + 5 files changed, 167 insertions(+), 83 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 05c073b46..7e32ddf8d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -81,6 +81,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 d0f3e12d9..7f2519f5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -16,6 +16,7 @@ internal static class LoggingExtensions 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 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ public static void EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(th _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 @@ public static void PostAuthenticationLocalRedirect(this ILogger logger, string r _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 df7caf331..066803e99 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.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 @@ public override async Task HandleRequestAsync() { 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 @@ protected virtual async Task HandleRemoteSignOutAsync() { 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 @@ protected virtual async Task HandleRemoteSignOutAsync() } /// - /// 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) - { - _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); - } + return; + } - 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; - } + Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); - // Attach the identity token to the logout request when possible. - message.IdTokenHint = await Context.Authentication.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); + if (_configuration == null && Options.ConfigurationManager != null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } - var redirectContext = new RedirectContext(Context, Options, properties) - { - ProtocolMessage = message - }; + 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) + }; - await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); - if (redirectContext.HandledResponse) + // 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)) { - Logger.RedirectToIdentityProviderForSignOutHandledResponse(); - return; + properties.RedirectUri = CurrentUri; } - else if (redirectContext.Skipped) + } + 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.RedirectToIdentityProviderForSignOutSkipped(); - return; + Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); } - message = redirectContext.ProtocolMessage; - - if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) + Response.Redirect(redirectUri); + } + else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) + { + var inputs = new StringBuilder(); + foreach (var parameter in message.Parameters) { - var redirectUri = message.CreateLogoutRequestUrl(); - if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) - { - Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); - } + var name = HtmlEncoder.Encode(parameter.Key); + var value = HtmlEncoder.Encode(parameter.Value); - Response.Redirect(redirectUri); + var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); + inputs.AppendLine(input); } - 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 issuer = HtmlEncoder.Encode(message.IssuerAddress); + var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var buffer = Encoding.UTF8.GetBytes(content); - 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"; - 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"; - // 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}"); + } + } - await Response.Body.WriteAsync(buffer, 0, buffer.Length); + /// + /// 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 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert 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 181444b05..c3b18b295 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -50,7 +50,9 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) }; /// - /// 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. + /// + 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 is sent to the OP as the redirect for the user-agent. + /// 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 4dfcc3662..e34ee5fb5 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -26,6 +26,7 @@ public override async Task HandleRequestAsync() { 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 263/611] 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 c3b18b295..9bd577923 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -128,7 +128,7 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 959d64ace..2862e1053 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 @@ public class OpenIdConnectMiddlewareTests 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 @@ public async Task SignOutSettingMessage() 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 @@ private static DateTime GetNonceExpirationTime(string keyname, TimeSpan nonceLif } } -} \ 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 264/611] 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 9bd577923..5c8bf8c0a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -128,7 +128,7 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 265/611] 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 7e32ddf8d..84558affb 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -81,7 +81,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) ClientSecret = clientSecret, // for code flow Authority = authority, ResponseType = OpenIdConnectResponseType.CodeIdToken, - PostLogoutRedirectUri = "/usersignout", + PostLogoutRedirectUri = "/signed-out", // GetClaimsFromUserInfoEndpoint = true, Events = new OpenIdConnectEvents() { @@ -128,10 +128,16 @@ await WriteHtmlAsync(context.Response, 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 266/611] 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 066803e99..80e8c693b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -73,10 +73,8 @@ public override async Task HandleRequestAsync() { return await HandleSignOutCallbackAsync(); } - else - { - return await base.HandleRequestAsync(); - } + + return await base.HandleRequestAsync(); } protected virtual async Task HandleRemoteSignOutAsync() @@ -156,7 +154,7 @@ protected override async Task HandleSignOutAsync(SignOutContext context) { if (context == null) { - return; + throw new ArgumentNullException(nameof(context)); } Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); @@ -168,9 +166,9 @@ protected override async Task HandleSignOutAsync(SignOutContext context) 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 @@ protected virtual Task HandleSignOutCallbackAsync() 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 5c8bf8c0a..12bc1c03d 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 267/611] 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 80e8c693b..7521ef39e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -147,7 +147,7 @@ protected virtual async Task HandleRemoteSignOutAsync() } /// - /// 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 @@ protected override async Task HandleSignOutAsync(SignOutContext context) 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 268/611] 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 7521ef39e..e5dcbbdeb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -152,11 +152,6 @@ protected virtual async Task HandleRemoteSignOutAsync() /// 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 1e642d82d..f992cde00 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -288,6 +288,11 @@ protected virtual Task HandleSignInAsync(SignInContext context) 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 269/611] 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 f11f69e1c..7c583ed7e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -57,11 +57,17 @@ private void CheckForRefresh(AuthenticationTicket 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); + 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 942b1c4a5..e6f881fef 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1214,6 +1214,51 @@ public async Task CanSpecifyAndShareDataProtector() 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 270/611] 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 efc1a5721..d7636fa32 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 271/611] 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 ffe687e5f..4364a2e54 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 @@ public class CookieAuthenticationEvents : ICookieAuthenticationEvents /// /// 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 @@ public class CookieAuthenticationEvents : ICookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -65,7 +66,7 @@ public class CookieAuthenticationEvents : ICookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -81,7 +82,7 @@ public class CookieAuthenticationEvents : ICookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -97,7 +98,7 @@ public class CookieAuthenticationEvents : ICookieAuthenticationEvents { 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 7ddff7ce8..1317797b6 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 38a877f66..8ac1c3631 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 @@ public class JwtBearerEvents : IJwtBearerEvents /// /// 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 2f8ea6072..7697e9b69 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 44c426051..066b324b7 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 @@ public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents /// /// 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 @@ public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents 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 192801ced..036517857 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 42d35b798..f39b554ec 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 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEve /// /// 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 5243a96a7..53379f96d 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 21c5b57a7..033227542 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 @@ public class TwitterEvents : RemoteAuthenticationEvents, ITwitterEvents /// /// 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 @@ public class TwitterEvents : RemoteAuthenticationEvents, ITwitterEvents 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 8696821dd..9d4aa7b4e 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 f992cde00..55cfa5b01 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,7 +142,7 @@ private async Task FinishResponseOnce() /// protected virtual Task FinishResponseAsync() { - return Task.FromResult(0); + return TaskCache.CompletedTask; } private async Task HandleAutomaticChallengeIfNeeded() @@ -283,7 +283,7 @@ public async Task SignInAsync(SignInContext context) protected virtual Task HandleSignInAsync(SignInContext context) { - return Task.FromResult(0); + return TaskCache.CompletedTask; } public async Task SignOutAsync(SignOutContext context) @@ -308,7 +308,7 @@ public async Task SignOutAsync(SignOutContext context) 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 7a2c47e40..27965dbf4 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 @@ public Task ChallengeAsync(ChallengeContext context) { return PriorHandler.ChallengeAsync(context); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } public void GetDescriptions(DescribeSchemesContext context) @@ -65,7 +66,7 @@ public Task SignInAsync(SignInContext context) { return PriorHandler.SignInAsync(context); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } public Task SignOutAsync(SignOutContext context) @@ -74,7 +75,7 @@ public Task SignOutAsync(SignOutContext context) { 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 ee45b8afd..6e7d6a35c 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 460549c7b..958170ab7 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 0e28ba077..4248e4813 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -67,7 +68,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 7f2671775..5bae319b3 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 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte { 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 aca1920d7..9fb295082 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 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 6e5aa7224..44e2b9a22 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -61,7 +62,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 8e72b62f8..303ba904a 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 272/611] 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 fa9e9ef1e..6899913af 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -13,6 +13,12 @@ public class AuthorizationOptions { 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 89777eab0..8980d51ac 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -8,6 +8,7 @@ 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, throw new ArgumentNullException(nameof(evaluator)); } + _options = options.Value; _handlers = handlers.ToArray(); _policyProvider = policyProvider; _logger = logger; @@ -89,6 +97,10 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE 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 7f9e5642a..039740ab2 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -20,11 +20,7 @@ private IAuthorizationService BuildAuthorizationService(Action(); } @@ -109,6 +105,72 @@ public async Task Authorize_ShouldAllowIfClaimIsAmongValues() 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 @@ public async Task CanBlockNonAuthenticatedUser() 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 273/611] 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 039740ab2..7b0fc8c8b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -20,6 +20,7 @@ private IAuthorizationService BuildAuthorizationService(Action(); } From e12838e38f5f8be8371c0a7b02d9ce47e0663ce0 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 21 Sep 2016 11:20:41 -0700 Subject: [PATCH 274/611] 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 55cfa5b01..5e9a7c238 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -311,6 +311,11 @@ protected virtual Task HandleSignOutAsync(SignOutContext context) 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 @@ protected virtual Task HandleForbiddenAsync(ChallengeContext context) /// 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 @@ protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) public async Task ChallengeAsync(ChallengeContext context) { ChallengeCalled = true; - var handled = false; if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticChallenge)) { switch (context.Behavior) @@ -347,18 +351,18 @@ public async Task ChallengeAsync(ChallengeContext context) } 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 aa9aef07c..2cf11669d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -75,6 +75,49 @@ public async Task AuthHandlerAuthenticateCachesTicket(string scheme) 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 @@ 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(); @@ -124,7 +169,7 @@ await handler.InitializeAsync( protected override Task HandleAuthenticateAsync() { - return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever"))); + return Task.FromResult(Result); } } @@ -220,7 +265,6 @@ public int StatusCode 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 275/611] 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 2ed873270..c84ec1bd9 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 71debecfa..000000000 --- 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 1317797b6..331de199a 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 c7bff38d1..26fe0809c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -9,6 +9,9 @@ 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 @@ public string GetRequestCookie(HttpContext context, string key) 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 @@ public void AppendResponseCookie(HttpContext context, string key, string value, { // 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) } 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 000000000..593e5d681 --- /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 000000000..a1a4f2184 --- /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 670baf5db..c978d169e 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 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 000000000..d95a6c128 --- /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 000000000..f5fab3f1e --- /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 276/611] #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 e34ee5fb5..862193db1 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -17,6 +17,7 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand 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 @@ protected virtual async Task HandleRemoteCallbackAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() } - 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 42cecf81b..d0a2cfa19 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -215,7 +215,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() } [Fact] - public async Task AuthenticateWillFail() + public async Task AuthenticateWithoutCookieWillFail() { var server = CreateServer(new GoogleOptions { @@ -755,6 +755,243 @@ public async Task CanRedirectOnError() 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 @@ private static TestServer CreateServer(GoogleOptions options, Func { var id = new ClaimsIdentity("xform"); @@ -789,6 +1031,10 @@ private static TestServer CreateServer(GoogleOptions options, Func Date: Thu, 22 Sep 2016 11:28:51 -0700 Subject: [PATCH 277/611] 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 9d4aa7b4e..395f67b3f 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 278/611] 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 68cc6054f..f28ab4d14 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -87,18 +87,20 @@ protected override async Task CreateTicketAsync( // 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 d0a2cfa19..944c322ad 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -43,8 +43,10 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() { "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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() 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 279/611] 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 7f2519f5f..aa6d0cbaa 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -37,7 +37,8 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ public static void UnableToReadAuthorizationResponseState(this ILogger logger) _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) + { + _responseError(logger, error, errorDescription, errorUri, null); + } + + public static void ResponseErrorWithStatusCode(this ILogger logger, string error, string errorDescription, string errorUri, int statusCode) { - _authorizationResponseError(logger, error, errorDescription, errorUri, null); + _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 e5dcbbdeb..2039a76e9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -507,14 +507,7 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( { return result; } + authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; @@ -684,20 +678,50 @@ private void PopulateSessionProperties(OpenIdConnectMessage message, Authenticat } /// - /// 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 @@ private async Task RunAuthorizationCodeReceive 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 @@ private string BuildRedirectUriIfRelative(string uri) 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 280/611] Add ChunkingCookieManager.Sources to NuGetPackageVerifier --- NuGetPackageVerifier.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 9f3414fbc..c522f4c1a 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 281/611] 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 7c583ed7e..1f2b395b1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -150,6 +150,7 @@ private CookieOptions BuildCookieOptions() HttpOnly = Options.CookieHttpOnly, Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), }; + if (Options.CookieSecure == CookieSecurePolicy.SameAsRequest) { cookieOptions.Secure = Request.IsHttps; @@ -158,6 +159,7 @@ private CookieOptions BuildCookieOptions() { cookieOptions.Secure = Options.CookieSecure == CookieSecurePolicy.Always; } + return cookieOptions; } @@ -172,13 +174,16 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task FinishResponseAsync() cookieValue, cookieOptions); - await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: ticket.Properties); + await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: properties); } } @@ -261,6 +266,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 282/611] 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 dbfa1ef92..1c5143842 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.Features.Authentication; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.WebUtilities; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -206,8 +207,7 @@ protected virtual string BuildChallengeUrl(AuthenticationProperties properties, 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 @@ protected virtual string BuildChallengeUrl(AuthenticationProperties properties, { "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 283/611] 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 2039a76e9..1e5eda470 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -806,12 +806,7 @@ protected virtual async Task GetUserInformationAsync(OpenIdC } // 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 000000000..dab4d0fd9 --- /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 284/611] 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 57ceb354a..4cf29c177 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 6530e1cf0..69c44692e 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 21d2365ec..e6658fa89 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 6aee5073f..4cbe064a3 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 a6a16a29f..2293569c3 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 227354e51..791666abc 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 331de199a..baa2b87c2 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 796b3bf7c..436b41be5 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 dde8c3a54..b4e4a8a46 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 7697e9b69..53c72471e 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 3169adf72..be590b3ec 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 036517857..c1d6ac079 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 53379f96d..3c7054a77 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 395f67b3f..28239ec93 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 958170ab7..4f0bc2bc9 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 303ba904a..fc455c84d 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 a1a4f2184..96571bb78 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 4cf5f4881..471dfc8a8 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 c7b3326a0..be6e48490 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 0feac5dd9..1fd82c9f5 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 f8fda41e3..6d723ec6b 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 f5fab3f1e..c060c077f 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 89673d848..9398f1df8 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 e622bd746..89709865e 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 285/611] 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 4cf29c177..2529f1402 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 69c44692e..8987d1b6a 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 e6658fa89..3a61c23ee 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 4cbe064a3..958f48d16 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 2293569c3..631e339af 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 791666abc..e2419deeb 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 1fd82c9f5..8bbb45320 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 6d723ec6b..c483cee31 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 c060c077f..0597e0fab 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 9398f1df8..df7e38f4a 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 286/611] 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 2529f1402..4cf29c177 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 8987d1b6a..69c44692e 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 3a61c23ee..e6658fa89 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 958f48d16..4cbe064a3 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 631e339af..2293569c3 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 e2419deeb..791666abc 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 8bbb45320..1fd82c9f5 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 c483cee31..6d723ec6b 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 0597e0fab..c060c077f 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 df7e38f4a..9398f1df8 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 287/611] 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 4cf29c177..2529f1402 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 69c44692e..8987d1b6a 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 e6658fa89..3a61c23ee 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 4cbe064a3..958f48d16 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 2293569c3..631e339af 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 791666abc..e2419deeb 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 1fd82c9f5..8bbb45320 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 6d723ec6b..c483cee31 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 c060c077f..0597e0fab 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 9398f1df8..df7e38f4a 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 288/611] 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 3c7054a77..234b9fd37 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 289/611] 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 53c72471e..7103ca254 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 290/611] #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 4f3a03d50..5bd848067 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -29,7 +29,7 @@ public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json"); + .AddJsonFile("appsettings.json", optional: true); if (env.IsDevelopment()) { @@ -77,7 +77,14 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } }); - // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 11477998c..000000000 --- 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 e2419deeb..e041bf26c 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 291/611] 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 958f48d16..2cfabe8df 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 292/611] 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 0fd623ffd..ad973186e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691..787f63ac0 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 f4208100e..355c68285 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 293/611] 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 dab4d0fd9..78eea68bf 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 @@ public static void AddClaimsToIdentity( } 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 294/611] #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 02611de8c..ac599bc57 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 @@ public class Startup { public Startup(IHostingEnvironment env) { + Environment = env; + var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath); @@ -30,6 +33,8 @@ public Startup(IHostingEnvironment env) 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 @@ public void Configure(IApplicationBuilder app) { // 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 37b753102..90ed3db25 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -20,6 +20,8 @@ public class Startup { public Startup(IHostingEnvironment env) { + Environment = env; + var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath); @@ -35,6 +37,8 @@ public Startup(IHostingEnvironment env) public IConfiguration Configuration { get; set; } + public IHostingEnvironment Environment { get; set; } + public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => @@ -75,8 +79,24 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 1e5eda470..9cc4fc2cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -578,7 +578,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ private async Task RunAuthorizationCodeReceive 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 12bc1c03d..f0b26f75b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -86,6 +86,7 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 fb97931cb..28f116d3d 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs @@ -33,6 +33,12 @@ public bool Succeeded /// 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 @@ public static AuthenticateResult Success(AuthenticationTicket ticket) 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 5e9a7c238..ae32424eb 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -58,6 +58,8 @@ protected string CurrentUri 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 @@ public async Task InitializeAsync(TOptions options, HttpContext context, ILogger 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 @@ internal async Task TeardownAsync() /// pipeline. public virtual Task HandleRequestAsync() { + if (InitializeResult?.Handled == true) + { + return Task.FromResult(true); + } return Task.FromResult(false); } @@ -250,7 +262,7 @@ protected Task HandleAuthenticateOnceAsync() /// /// 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 24f3ba8e5..4039a0560 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -51,7 +51,14 @@ public bool CheckEventResult(out AuthenticateResult result) { 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 862193db1..1e41fb0b5 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -43,6 +43,10 @@ protected virtual async Task HandleRemoteCallbackAsync() { 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 fea01b36f..c0d2ddba5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -429,6 +429,39 @@ public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() 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 @@ public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() 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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() 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 @@ public async Task EventOnChallengeSkipped_ResponseNotModified() 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 000000000..a212af649 --- /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 295/611] 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 26fe0809c..16426507c 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 @@ 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; + 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 296/611] 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 c07a314b0..c0663295c 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 297/611] 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 7103ca254..f2e9b5dd2 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 234b9fd37..33f13c66c 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 298/611] #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 9cc4fc2cd..6c3c2e938 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -208,6 +208,12 @@ protected override async Task HandleSignOutAsync(SignOutContext context) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 fc9338e2b..b9c0179af 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -222,6 +222,7 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceMessage() { var newMessage = new MockOpenIdConnectMessage { + IssuerAddress = "http://example.com/", TestAuthorizeEndpoint = $"http://example.com/{Guid.NewGuid()}/oauth2/signin" }; @@ -322,5 +323,16 @@ public async Task ChallengeSetsNonceAndStateCookies() 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 2862e1053..6c427c600 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -135,6 +135,17 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 299/611] #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 6c3c2e938..6691c4ed6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -541,7 +541,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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) - { - // 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; + // 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); + // 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); - nonce = jwt?.Payload.Nonce; + // 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) + { + 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 300/611] 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 6691c4ed6..c9c513ea7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -150,7 +150,7 @@ protected virtual async Task HandleRemoteSignOutAsync() /// 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 @@ protected override async Task HandleSignOutAsync(SignOutContext context) }; // 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 301/611] 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 000000000..56e48d3fe --- /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 000000000..56e48d3fe --- /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 000000000..1e070fc7f --- /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 000000000..1e070fc7f --- /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 000000000..647633afa --- /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 000000000..647633afa --- /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 000000000..37e18e53e --- /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 000000000..37e18e53e --- /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 000000000..06b3cd0d5 --- /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 000000000..06b3cd0d5 --- /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 000000000..d485aedb1 --- /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 000000000..d485aedb1 --- /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 000000000..64cb79487 --- /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 000000000..64cb79487 --- /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 000000000..c35232a31 --- /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 000000000..c35232a31 --- /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 000000000..1f69da5a8 --- /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 000000000..1f69da5a8 --- /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 000000000..8ae585270 --- /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 000000000..8ae585270 --- /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 000000000..8eef347eb --- /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 000000000..8eef347eb --- /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 000000000..1fc242ec5 --- /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 302/611] 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 0fd623ffd..ad973186e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691..24ca167cf 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 f4208100e..fea9ac64a 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 303/611] 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 2529f1402..ae4abcc28 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 8987d1b6a..0892ae8fb 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 3a61c23ee..a70a9bea9 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 2cfabe8df..26da355f3 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 631e339af..c429cfd2b 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 e041bf26c..c46f461b7 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 baa2b87c2..8cdb4bf1e 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 436b41be5..5f60a7f81 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 b4e4a8a46..1b24f2c99 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 f2e9b5dd2..65a388824 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 be590b3ec..7a2a8436b 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 c1d6ac079..565b72537 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 33f13c66c..dc137510a 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 28239ec93..c4fa7ea46 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 4f0bc2bc9..2006c8497 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 fc455c84d..3875aae17 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 96571bb78..693fba630 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 471dfc8a8..5a0eca5f4 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 be6e48490..82e22660d 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 8bbb45320..719a55c19 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 c483cee31..15bb60f49 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 0597e0fab..920882e45 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 df7e38f4a..cce61bd69 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 89709865e..bd37d47b9 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 304/611] 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 f4208100e..4fd7ede78 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 305/611] 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 983ba0401..f45e8cc92 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 306/611] 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 d7636fa32..a0be88689 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 307/611] Removed packages list in NuGetPackageVerifier.json --- NuGetPackageVerifier.json | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index c522f4c1a..348835e2d 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 308/611] #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 ae32424eb..8e7e42765 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -327,7 +327,6 @@ protected virtual Task HandleSignOutAsync(SignOutContext context) /// 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 @@ protected virtual Task HandleForbiddenAsync(ChallengeContext context) /// 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 @@ protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) public async Task ChallengeAsync(ChallengeContext context) { ChallengeCalled = true; + var handled = false; if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticChallenge)) { switch (context.Behavior) @@ -363,18 +363,18 @@ public async Task ChallengeAsync(ChallengeContext context) } 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 2cf11669d..fade43716 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -75,16 +75,17 @@ public async Task AuthHandlerAuthenticateCachesTicket(string scheme) 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 309/611] 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 f45e8cc92..0ad1995dd 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 ae4abcc28..9815401c9 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 0892ae8fb..728956503 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 a70a9bea9..794cc4a6a 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 26da355f3..9d3c75d28 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 c429cfd2b..446afd02a 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 c46f461b7..c1cf78b49 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 8cdb4bf1e..454540392 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 5f60a7f81..4d581dce1 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 1b24f2c99..f8d8e3417 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 65a388824..271e35339 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 7a2a8436b..634b455af 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 565b72537..525f21fc0 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 dc137510a..1b513d926 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 c4fa7ea46..2d31ec0b2 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 2006c8497..0dcf5a789 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 3875aae17..883e92641 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 693fba630..7ccf0307d 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 5a0eca5f4..95eede5db 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 82e22660d..54b4c97cc 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 719a55c19..7477e93fa 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 15bb60f49..dfb4e7288 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 920882e45..d8761ffa3 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 cce61bd69..d849b6bc2 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 bd37d47b9..43738eba9 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 310/611] 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 c84ec1bd9..50805feb1 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 8f2f99691..0605b59c0 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 4fd7ede78..07997d6c8 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 000000000..700582a85 --- /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 0ad1995dd..000000000 --- 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 000000000..f5ea5ac9e --- /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 000000000..623896b73 --- /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 f6575c3e0..000000000 --- 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 9815401c9..000000000 --- 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 000000000..fb189cef4 --- /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 1c347c845..000000000 --- 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 728956503..000000000 --- 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 000000000..2d94cdbdf --- /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 97f5837ce..000000000 --- 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 794cc4a6a..000000000 --- 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 000000000..7331e7f05 --- /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 26e9f9030..000000000 --- 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 9d3c75d28..000000000 --- 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 000000000..dfb023107 --- /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 9029ad0f1..000000000 --- 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 446afd02a..000000000 --- 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 000000000..71900b9b5 --- /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 b439f74d1..000000000 --- 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 c1cf78b49..000000000 --- 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 000000000..d3fc56ba8 --- /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 000000000..0eb708b9b --- /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 000000000..955afcb39 --- /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 238c0cec6..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 454540392..000000000 --- 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 000000000..a99538405 --- /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 caa72075e..000000000 --- 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 76feceeff..000000000 --- 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 4d581dce1..000000000 --- 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 000000000..cce86fac6 --- /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 ab6048872..000000000 --- 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 76feceeff..000000000 --- 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 f8d8e3417..000000000 --- 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 000000000..41d886031 --- /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 738458398..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 271e35339..000000000 --- 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 000000000..341096369 --- /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 a4ccc9863..000000000 --- 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 76feceeff..000000000 --- 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 634b455af..000000000 --- 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 000000000..1199750e8 --- /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 20b825dca..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 525f21fc0..000000000 --- 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 000000000..407dc44ae --- /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 6a07e8120..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 1b513d926..000000000 --- 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 000000000..a81a88380 --- /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 b72a631fa..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 2d31ec0b2..000000000 --- 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 000000000..ed11f94ad --- /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 b3345c6cf..000000000 --- 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 76feceeff..000000000 --- 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 000000000..408ef6b22 --- /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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 0dcf5a789..000000000 --- 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 000000000..75a9511f3 --- /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 cc6041f8f..000000000 --- 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 76feceeff..000000000 --- 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 000000000..67a87fca5 --- /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 000000000..5015e3aba --- /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 883e92641..000000000 --- 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 593e5d681..000000000 --- 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 7ccf0307d..000000000 --- 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 000000000..af3b620b4 --- /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 0cd49f324..000000000 --- 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 76feceeff..000000000 --- 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 95eede5db..000000000 --- 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 000000000..eae395d84 --- /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 052e99816..000000000 --- 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 56cb77fdc..490fa7cb2 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 54b4c97cc..000000000 --- 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 000000000..0eb8b1269 --- /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 1050a47ad..000000000 --- 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 7477e93fa..000000000 --- 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 000000000..f4d6f8c66 --- /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 59bcbc9c4..000000000 --- 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 dfb4e7288..000000000 --- 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 000000000..21ded78c8 --- /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 d95a6c128..000000000 --- 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 d8761ffa3..000000000 --- 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 000000000..c048cdd25 --- /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 06582d576..000000000 --- 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 d849b6bc2..000000000 --- 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 000000000..23815e0cc --- /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 d7f7c9d95..000000000 --- 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 43738eba9..000000000 --- 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 000000000..e77c8d9c3 --- /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 311/611] 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 623896b73..7a3ab4792 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 fb189cef4..4a77be127 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 2d94cdbdf..273cfaf89 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 7331e7f05..ef7bcae73 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 dfb023107..78d799be1 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 71900b9b5..1af3fe1c2 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 955afcb39..bdbcff276 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 a99538405..999bb8bd8 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 cce86fac6..e66ceff78 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 41d886031..e95df79ce 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 341096369..0af3a9d0d 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 1199750e8..1bb635bfc 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 407dc44ae..a90a4846c 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 a81a88380..b7222fd9c 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 ed11f94ad..edc85f76e 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 af3b620b4..0d0e37c80 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 eae395d84..7ec8078c5 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 0eb8b1269..23cc33121 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 f4d6f8c66..2d8f9652b 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 21ded78c8..cf2a629d4 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 c048cdd25..ac8319106 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 23815e0cc..344294e72 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 312/611] Upgrade appveyor image --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b9a9bcd1e..c6b856f49 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 313/611] 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 afe862f4f..38ca6fc37 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 edb6e4dd1..25de3e478 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 e89788c48..6922375c9 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 62dc4ef77..e6436fee2 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 48610115f..058fa4c5d 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 251bfbffd..30bf2e5f6 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 314/611] 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 49cbf139d..741dd6ebf 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 @@ public static void Main(string[] args) 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 f3cad66ad..483feec16 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 @@ public static void Main(string[] args) 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 315/611] 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 0fd623ffd..93f1ac47d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,7 @@ + diff --git a/build/common.props b/build/common.props index 700582a85..f2d9508e5 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 316/611] 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 23cc33121..39c01086e 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 2d8f9652b..424132eb2 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 cf2a629d4..4c4da177f 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 ac8319106..b46df5b99 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 344294e72..d78da4397 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 317/611] 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 483feec16..76fb5e59a 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -19,7 +19,7 @@ public static void Main(string[] args) 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 318/611] 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 84558affb..5b18a0e13 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -95,7 +95,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 319/611] #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 ef7bcae73..9b27985b7 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 e95df79ce..db5d30bd2 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 a90a4846c..d6b200629 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 320/611] 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 000000000..1e3e060e8 --- /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 321/611] 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 f2d9508e5..7ce50d277 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 1e3e060e8..000000000 --- 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 f5ea5ac9e..76d5bf85e 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 7a3ab4792..e9987f3a8 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 4a77be127..62bb9f4a9 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 273cfaf89..83c0c643d 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 9b27985b7..6cb421a2a 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 78d799be1..acbae28b4 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 1af3fe1c2..1c137b6d5 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 d3fc56ba8..000000000 --- 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 000000000..70c6cdbf2 --- /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 0eb708b9b..000000000 --- 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 bdbcff276..01f5b635d 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 999bb8bd8..7d7e3ad04 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 e66ceff78..30545dd69 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 db5d30bd2..b53e5ee85 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 0af3a9d0d..559b78a3c 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 1bb635bfc..3a0ad122c 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 d6b200629..72da65f4c 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 b7222fd9c..0368a8be0 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 edc85f76e..e93061de6 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 408ef6b22..000000000 --- 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 fdc54f10b..6a1c60f94 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 67a87fca5..000000000 --- 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 5015e3aba..000000000 --- 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 0d0e37c80..2f5b094c0 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 7ec8078c5..4c6cb7a83 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 39c01086e..0a9adfd43 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 424132eb2..62b041f37 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 4c4da177f..672309b92 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 b46df5b99..91e98ad98 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 d78da4397..408703450 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 322/611] 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 b53e5ee85..1e8ecac61 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 72da65f4c..aa4442313 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 323/611] 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 1e8ecac61..b53e5ee85 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 aa4442313..72da65f4c 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 324/611] 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 b53e5ee85..1e8ecac61 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 72da65f4c..aa4442313 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 325/611] Simplify packing --- shared/sources.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shared/sources.csproj b/shared/sources.csproj index 70c6cdbf2..d8796f1a4 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 326/611] 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 0f9c2a30a..e1c79192a 100644 --- a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs +++ b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs @@ -7,7 +7,7 @@ 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 @@ public DateTimeOffset UtcNow { // 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 327/611] 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 ac599bc57..4d1ca7476 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -24,7 +24,7 @@ public Startup(IHostingEnvironment env) 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 5b18a0e13..ec80cd651 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -28,7 +28,7 @@ public Startup(IHostingEnvironment env) 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 90ed3db25..587e1e9c1 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -28,7 +28,7 @@ public Startup(IHostingEnvironment env) 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 5bd848067..4c0faaa16 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -34,7 +34,7 @@ public Startup(IHostingEnvironment env) 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 328/611] 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 348835e2d..974eb365c 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 76d5bf85e..000000000 --- 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 d8796f1a4..000000000 --- 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 329/611] 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 7ce50d277..52413444e 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 000000000..e704edaec --- /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 e9987f3a8..a2cab9171 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 62bb9f4a9..aa5f0ca27 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 83c0c643d..790bd0827 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 6cb421a2a..8c8c3f2b1 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 acbae28b4..5a9683f6c 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 1c137b6d5..30f0742de 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 01f5b635d..0d7dd0430 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 7d7e3ad04..6be798cc1 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 30545dd69..dc6ef94d6 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 1e8ecac61..518526d41 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 559b78a3c..5f9a5bb3e 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 3a0ad122c..e40377c09 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 aa4442313..e5665f579 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 0368a8be0..78557532c 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 e93061de6..3b5c7d631 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 6a1c60f94..d1360f868 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 2f5b094c0..862ab2ac7 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 4c6cb7a83..153eb6ae9 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 0a9adfd43..66d9dfed6 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 62b041f37..b57e09904 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 672309b92..f5ca9c2d3 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 91e98ad98..f0a8a28d9 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 408703450..09433d299 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 330/611] 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 000000000..d4bab3eeb --- /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 331/611] 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 66d9dfed6..446469ba4 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 b57e09904..5eaa318a3 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 f5ca9c2d3..0cf30727b 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 f0a8a28d9..aa00d90e0 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 09433d299..635fffe33 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 332/611] #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 4c0faaa16..42ce6a29d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -112,7 +112,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } 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 be1c8f8f8..3c3c14c86 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -45,90 +45,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 48e359099..000000000 --- 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 8e86b37c1..ae875bfaf 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 @@ public FacebookOptions() 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 f28ab4d14..87506e080 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -42,42 +42,7 @@ protected override async Task CreateTicketAsync( 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 336536c51..2cac949a0 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 @@ public static string GetEmail(JObject user) 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 3d93b96ea..d26977970 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 @@ public GoogleOptions() 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 21f567d15..2426cafe0 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -35,39 +35,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 cce8dcc73..000000000 --- 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 625d4baf9..1aa4009a5 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 @@ public MicrosoftAccountOptions() 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 000000000..965ca5fdb --- /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 000000000..63da155d7 --- /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 000000000..f3fee6a22 --- /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 000000000..21a4f70e1 --- /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 000000000..75167cabc --- /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 000000000..e628904de --- /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 000000000..bc29672d0 --- /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 15f9c91c7..b17d23c9b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -144,5 +144,23 @@ public TimeSpan? ExpiresIn /// 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 1c5143842..a5c36c1c4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -11,11 +11,10 @@ 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 9591d9c44..9bd08dfd8 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 @@ public OAuthOptions() 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 000000000..4e349579f --- /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 000000000..132885b3c --- /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 e5665f579..965a940e4 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 c9c513ea7..a7c20f62e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -661,6 +661,14 @@ protected override async Task HandleRemoteAuthenticateAsync( { 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( // 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private void WriteNonceCookie(string nonce) ///
/// 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 f0b26f75b..a46c2956c 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 @@ public OpenIdConnectOptions(string authenticationScheme) /// /// 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 78eea68bf..000000000 --- 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 435196a1e..21c6189d7 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 78557532c..3694159f6 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 20d06beaf..8481730a8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -108,6 +108,11 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ private async Task RetrieveUserDetailsAsync(AccessToken accessToken, Cl 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 bf54b7fbb..836dd3c0d 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 @@ public TwitterOptions() CallbackPath = new PathString("/signin-twitter"); BackchannelTimeout = TimeSpan.FromSeconds(60); Events = new TwitterEvents(); + + ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); } /// @@ -46,6 +49,11 @@ public TwitterOptions() /// 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 944c322ad..2a47f1e89 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -653,11 +653,11 @@ public async Task ValidateAuthenticatedContext() 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 446469ba4..3ae22642f 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 5eaa318a3..7b6b30b8c 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 0cf30727b..9c49dcd29 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 aa00d90e0..ced555fe9 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 333/611] 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 0605b59c0..5bf0e2c11 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 07997d6c8..b0bcadb57 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 334/611] 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 a0be88689..af659e9ae 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 c6b856f49..944c23c8b 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 335/611] Update .travis.yml (#1138) --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index af659e9ae..b8f60ce2e 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 336/611] 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 42ce6a29d..e99be82f8 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -110,7 +110,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 337/611] 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 e99be82f8..31ec187a0 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -238,9 +238,9 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 338/611] 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 a7c20f62e..6b24996e7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -161,6 +161,7 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ private async Task RunAuthorizationCodeReceive 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 a46c2956c..8269acbd8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -241,5 +241,12 @@ public OpenIdConnectOptions(string authenticationScheme) /// 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 b9c0179af..1912561b1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -35,7 +35,23 @@ public async Task ChallengeIsIssuedCorrectly() 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 @@ Example of a form post */ [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 6c427c600..a58d54b65 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -46,7 +46,25 @@ public async Task SignOutSettingMessage() 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 3e50a7abe..a3bea3ebe 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.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 @@ private void ValidateParameters( 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 @@ private void ValidateResource(IDictionary actualQuery, ICollecti 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 339/611] 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 635fffe33..32c20ae4f 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 340/611] 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 8c8c3f2b1..695c6d556 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 5a9683f6c..6df114101 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 341/611] 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 b8f60ce2e..e4c69a2a0 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 944c23c8b..1041615c6 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 342/611] 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 f38ca8afc..4d6cabaf1 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.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -163,7 +164,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() { 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 2a47f1e89..090f9f121 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.Features.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -293,7 +294,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) [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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla [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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) [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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) [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 @@ public async Task AuthenticatedEventCanGetRefreshToken() [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 @@ public async Task NullRedirectUriWillRedirectToSlash() [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 @@ public async Task NoStateCausesException() [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 @@ public async Task CanRedirectOnError() [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 @@ public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() [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 @@ public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() [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 @@ public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() [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 @@ public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() [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 0ddfb5a3c..0ed164e49 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.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -103,7 +104,7 @@ public async Task ChallengeWillTriggerRedirection() [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 343/611] 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 e704edaec..8ad6e2f5a 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 a2cab9171..9b2137343 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 f7ac67933..000000000 --- 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 aa5f0ca27..96af9da08 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 f7ac67933..000000000 --- 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 790bd0827..890af4eee 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 f7ac67933..000000000 --- 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 695c6d556..62adb1667 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 f7ac67933..000000000 --- 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 6df114101..ba79d1a8c 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 f7ac67933..000000000 --- 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 30f0742de..33e6e5052 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 0d7dd0430..092631fdf 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 518526d41..18e06c92e 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 e40377c09..f6f808957 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 965a940e4..4eb7fd2a1 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 3694159f6..2b34f1d1b 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 3b5c7d631..0e9afba51 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 d1360f868..0cdd0b267 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 862ab2ac7..344d18f25 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 153eb6ae9..b77907364 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 3ae22642f..d0505f36a 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 7b6b30b8c..a50fc3b01 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 9c49dcd29..ea08bbc2f 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 ced555fe9..d2a567d1e 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 32c20ae4f..6a869b23f 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 344/611] 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 37dda75a7..767e336ac 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 345/611] 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 e4c69a2a0..2a4610467 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 346/611] 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 0f91ad120..bcc811de9 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 8ad6e2f5a..b58dd4cd7 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 9b2137343..9fd7e9412 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 96af9da08..e4a42b8c4 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 890af4eee..bfff3d519 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 62adb1667..a5982549b 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 ba79d1a8c..eaf3a2e87 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 33e6e5052..09ece106c 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 092631fdf..4a711c318 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 6be798cc1..8fddfe520 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 dc6ef94d6..82a3e474e 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 18e06c92e..90566e779 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 5f9a5bb3e..ac91578ea 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 f6f808957..c0e7569ac 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 4eb7fd2a1..2367369a4 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 2b34f1d1b..dc4bbf80a 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 0e9afba51..316defc43 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 0cdd0b267..0382fd2b5 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 344d18f25..146917cab 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 b77907364..1a6679119 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 d0505f36a..bbf54ec5e 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 a50fc3b01..d9065add3 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 ea08bbc2f..729c01630 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 d2a567d1e..f4507a37b 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 6a869b23f..003e1a18b 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 347/611] 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 90566e779..7311aa3ae 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 2367369a4..351cb284c 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 f4507a37b..b9155b4df 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 003e1a18b..02763b93f 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 348/611] 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 8fddfe520..0cef42b39 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 82a3e474e..491571371 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 ac91578ea..eecfeb926 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 349/611] 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 b58dd4cd7..8acb4fe47 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 350/611] 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 52413444e..9c5464a54 100644 --- a/build/common.props +++ b/build/common.props @@ -13,7 +13,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index 8acb4fe47..c5193b750 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 351/611] 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 c5193b750..b9ac0f5f0 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 e77c8d9c3..44cb2290b 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 352/611] 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 | 93 +-- .../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 | 326 +++----- .../AuthenticationMiddleware.cs | 83 +- .../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 | 142 ++-- .../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} | 751 ++++++++---------- .../DynamicSchemeTests.cs | 134 ++++ ...ookMiddlewareTests.cs => FacebookTests.cs} | 233 ++++-- ...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 | 118 ++- .../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, 4242 insertions(+), 4992 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 50805feb1..81d0cc4b9 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 002d87888..0480556f6 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 @@ public class Startup { 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 ecb61ab66..ca21070dc 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -4,6 +4,7 @@ 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 @@ public class Startup { 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 bfff3d519..1f9310329 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 4d1ca7476..9df41a9ab 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 @@ public Startup(IHostingEnvironment env) // 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 @@ public void Configure(IApplicationBuilder app) } 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 @@ public void Configure(IApplicationBuilder app) }); } } -} - +} \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs index 54989c13a..7d9b39121 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 @@ private void BeforeAccessNotificationWithProperties(TokenCacheNotificationArgs a 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 @@ private void AfterAccessNotificationWithContext(TokenCacheNotificationArgs args) 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 a5982549b..a37c3659d 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 ec80cd651..19bb0ac6a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -3,12 +3,12 @@ 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 @@ public Startup(IHostingEnvironment env) 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); - } - - 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; - } - } + sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); + services.AddCookieAuthentication(); - 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 + services.AddOpenIdConnectAuthentication(o => { - ClientId = clientId, - ClientSecret = clientSecret, // for code flow - Authority = authority, - ResponseType = OpenIdConnectResponseType.CodeIdToken, - PostLogoutRedirectUri = "/signed-out", + o.ClientId = ClientId; + o.ClientSecret = ClientSecret; // for code flow + o.Authority = Authority; + o.ResponseType = OpenIdConnectResponseType.CodeIdToken; + o.PostLogoutRedirectUri = "/signed-out"; // GetClaimsFromUserInfoEndpoint = true, - Events = new OpenIdConnectEvents() + 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 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.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); + + app.UseDeveloperExceptionPage(); + + app.UseAuthentication(); app.Run(async context => { @@ -111,13 +98,11 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ await WriteHtmlAsync(context.Response, } 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 @@ await WriteHtmlAsync(context.Response, } 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 @@ await WriteHtmlAsync(context.Response, { 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 @@ await WriteHtmlAsync(context.Response, async response => 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 eaf3a2e87..74661c2f3 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 587e1e9c1..5faa48b52 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -3,12 +3,12 @@ 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 @@ public Startup(IHostingEnvironment env) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => // 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 09ece106c..fe63ab5ca 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 31ec187a0..3f64d813d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -14,7 +14,6 @@ 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 @@ public Startup(IHostingEnvironment env) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) */ // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { // 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) } 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 765d1f51c..bb5cdfff0 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 ad0e17a09..700b60797 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs @@ -6,7 +6,7 @@ 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 1f2b395b1..017e7911c 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 @@ private Task EnsureCookieTicket() 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 @@ private void RequestRefresh(AuthenticationTicket ticket) 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 @@ private async Task ReadCookieTicket() 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 @@ private async Task ReadCookieTicket() } } - var currentUtc = Options.SystemClock.UtcNow; + var currentUtc = Clock.UtcNow; var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; @@ -126,8 +191,8 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ private CookieOptions BuildCookieOptions() 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 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task FinishResponseAsync() 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) } else { - issuedUtc = Options.SystemClock.UtcNow; + issuedUtc = Clock.UtcNow; signInContext.Properties.IssuedUtc = issuedUtc; } @@ -244,7 +311,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); } - await Options.Events.SigningIn(signInContext); + await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { @@ -264,7 +331,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signOutContext) 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 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr 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 @@ private static bool IsHostRelative(string path) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con } 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 14d152a81..000000000 --- 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 b42561250..56d6ca238 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 @@ public class CookieAuthenticationOptions : AuthenticationOptions, IOptions 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 @@ public string CookieName 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 @@ public string CookieName 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 @@ public string CookieName 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 @@ public string CookieName /// 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 000000000..e8a21d01b --- /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 e5423fed2..4c949bb08 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 @@ public BaseCookieContext( } 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 4364a2e54..5cb933ce1 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 2cbb5ff09..e4259d181 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -8,7 +8,7 @@ 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 @@ public class CookieRedirectContext : BaseCookieContext /// 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 cfb7c5f1d..0e610c8b2 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 @@ public class CookieSignedInContext : BaseCookieContext /// 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 d8b2307f3..b91cb7e18 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 @@ public class CookieSigningInContext : BaseCookieContext /// 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 51c04a56b..0f4f4c7dc 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 @@ public class CookieSigningOutContext : BaseCookieContext /// /// /// + /// /// /// /// 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 @@ public CookieSigningOutContext( /// 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 57a28191c..3232ba52f 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 @@ public class CookieValidatePrincipalContext : BaseCookieContext /// 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 @@ public CookieValidatePrincipalContext(HttpContext context, AuthenticationTicket } Principal = ticket.Principal; - Properties = ticket.Properties; } /// @@ -48,11 +46,6 @@ public CookieValidatePrincipalContext(HttpContext context, AuthenticationTicket /// 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 1406d872d..000000000 --- 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 4a711c318..3f2f0ee8d 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 0435db794..1a9607eea 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 000000000..9305623da --- /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 000000000..bcfa95c0a --- /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 3c3c14c86..521684d14 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 ac57e8dde..000000000 --- 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 ae875bfaf..7010bb20a 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 @@ public class FacebookOptions : OAuthOptions /// public FacebookOptions() { - AuthenticationScheme = FacebookDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-facebook"); SendAppSecretProof = true; AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; @@ -49,6 +49,24 @@ public FacebookOptions() 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 0cef42b39..8f46ff169 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 85a193d82..d2687239b 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 000000000..e19c1fdb1 --- /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 000000000..d85e3a2d6 --- /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 87506e080..c699f5cc9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -6,21 +6,22 @@ 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 @@ protected override async Task CreateTicketAsync( 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 5f8afaff2..000000000 --- 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 d26977970..34028bc52 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 @@ public class GoogleOptions : OAuthOptions /// 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 491571371..7b6c9ee5d 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 b3e0f0bdc..b47a9bab0 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 5c28f2976..313e999d0 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 @@ public BaseJwtBearerContext(HttpContext context, JwtBearerOptions options) 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 a7b8aeb55..000000000 --- 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 584681253..e6f931f6d 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 8ac1c3631..c4e2e7b5a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -8,9 +8,9 @@ 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 a23f8356d..530a945ca 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 d6de5ca87..3667865da 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 13c06ca38..6b1b1afd4 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 000000000..f3571a49c --- /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 000000000..77ffd76ff --- /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 ee5575251..2ea03a51f 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 @@ internal class JwtBearerHandler : AuthenticationHandler { 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } } @@ -120,15 +181,15 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() { 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 @@ protected override async Task HandleAuthenticateAsync() } } - 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con eventContext.ErrorDescription = CreateErrorDescription(eventContext.AuthenticateFailure); } - await Options.Events.Challenge(eventContext); - if (eventContext.HandledResponse) - { - return true; - } - if (eventContext.Skipped) + await Events.Challenge(eventContext); + if (eventContext.IsProcessingComplete(out var ignored)) { - return false; + return; } Response.StatusCode = 401; @@ -259,8 +315,6 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 bfb38793f..000000000 --- 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 2aedf30d5..9a480763d 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 @@ public JwtBearerOptions() : base() 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 @@ public JwtBearerOptions() : base() /// /// 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 7311aa3ae..89e7ef9c3 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 eecfeb926..5b8263c9c 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 660dd2e81..88306efbe 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 000000000..520c3758d --- /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 000000000..1f8884ab2 --- /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 2426cafe0..b2b787b97 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 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 3ad1bf557..000000000 --- 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 1aa4009a5..dbca3507e 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -5,11 +5,12 @@ 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 @@ public class MicrosoftAccountOptions : OAuthOptions /// 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 29316732c..000000000 --- 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 b17d23c9b..f50dff3f5 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.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 @@ public OAuthCreatingTicketContext( /// /// 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 @@ public OAuthCreatingTicketContext( 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 @@ public OAuthCreatingTicketContext( 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 066b324b7..4e94a15bc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -8,9 +8,9 @@ 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 @@ public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents 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 63eaa3537..5d5e0e701 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 eebeaf7a3..ceec294ec 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 000000000..aa7c59f03 --- /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 a5c36c1c4..cafc4f0bc 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.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 + { + get { return (OAuthEvents)base.Events; } + 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) + { } + + protected override void InitializeOptions() { - Backchannel = backchannel; + 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); + } } - protected HttpClient Backchannel { get; private set; } + /// + /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( { // 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 @@ private static async Task Display(HttpResponseMessage response) 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 75139c1c8..000000000 --- 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 9bd08dfd8..3c71f055f 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 @@ public OAuthOptions() 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 @@ public OAuthOptions() 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 776f78d6e..0c7d96863 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 49c863e4b..0ccfc3ab7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -18,8 +18,8 @@ public class AuthorizationCodeReceivedContext : BaseOpenIdConnectContext /// /// 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 @@ public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOption /// /// 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 @@ public void HandleCodeRedemption() } /// - /// 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 @@ public void HandleCodeRedemption(string accessToken, string idToken) } /// - /// 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 d2f56a4ce..63f815d9e 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 128fa08a3..000000000 --- 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 b2554969c..f0298ed05 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 f39b554ec..f6386aeec 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -8,9 +8,9 @@ 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 59b1c0efd..59b00827a 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 a76dc9e59..5c0172673 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 @@ public class RemoteSignOutContext : BaseOpenIdConnectContext { 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 b4a9ad6d1..7c0d51fbb 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 @@ public class TokenResponseReceivedContext : BaseOpenIdConnectContext /// /// 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 130a4d987..fea89298c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs @@ -15,8 +15,8 @@ public class TokenValidatedContext : BaseOpenIdConnectContext /// /// 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 c0a53db44..ee80cb71f 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 351cb284c..a5e4c8b0c 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 dde12494d..db5cfbbcc 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 000000000..9afae436d --- /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 a099a7276..c5baca4db 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 000000000..89581b201 --- /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 6b24996e7..69acbf9a0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,12 +13,12 @@ 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 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler 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 @@ protected virtual async Task HandleRemoteSignOutAsync() 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 @@ protected virtual async Task HandleRemoteSignOutAsync() // 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 @@ protected virtual async Task HandleRemoteSignOutAsync() 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) }; // 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) 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 @@ protected virtual Task HandleSignOutCallbackAsync() if (!string.IsNullOrEmpty(properties?.RedirectUri)) { Response.Redirect(properties.RedirectUri); - return Task.FromResult(true); } } @@ -282,7 +364,7 @@ protected virtual Task HandleSignOutCallbackAsync() /// 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con // 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con } Response.Redirect(redirectUri); - return true; + return; } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { @@ -407,7 +488,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail("No message."); } @@ -473,7 +554,7 @@ protected override async Task HandleRemoteAuthenticateAsync( } var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); - if (messageReceivedContext.CheckEventResult(out result)) + if (messageReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -489,7 +570,7 @@ protected override async Task HandleRemoteAuthenticateAsync( Logger.NullOrEmptyAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } @@ -504,7 +585,7 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } @@ -550,7 +631,7 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket); - if (tokenResponseReceivedContext.CheckEventResult(out result)) + if (tokenResponseReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -620,7 +701,7 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (authenticationFailedContext.CheckEventResult(out result)) + if (authenticationFailedContext.IsProcessingComplete(out result)) { return result; } @@ -804,7 +885,7 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessag 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 @@ private void WriteNonceCookie(string nonce) { HttpOnly = true, Secure = Request.IsHttps, - Expires = Options.SystemClock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) + Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); } @@ -971,13 +1052,13 @@ private AuthenticationProperties GetPropertiesFromState(string state) 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 @@ private async Task RunMessageReceivedEventAsync(OpenIdCo 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 @@ private async Task RunTokenValidatedEventAsync(OpenIdConn Nonce = nonce, }; - await Options.Events.TokenValidated(tokenValidatedContext); + await Events.TokenValidated(tokenValidatedContext); if (tokenValidatedContext.HandledResponse) { Logger.TokenValidatedHandledResponse(); @@ -1029,7 +1110,7 @@ private async Task RunAuthorizationCodeReceive 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 @@ private async Task RunAuthorizationCodeReceive Backchannel = Backchannel, }; - await Options.Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); + await Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); if (authorizationCodeReceivedContext.HandledResponse) { Logger.AuthorizationCodeReceivedContextHandledResponse(); @@ -1059,14 +1140,14 @@ private async Task RunTokenResponseReceivedEventAs 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 @@ private async Task RunUserInformationReceivedEve { 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 @@ private async Task RunUserInformationReceivedEve 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 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert 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 @@ private OpenIdConnectProtocolException CreateOpenIdConnectProtocolException(Open 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 8d880d0d9..000000000 --- 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 8269acbd8..5ca270dde 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -8,27 +8,20 @@ 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 @@ public OpenIdConnectOptions() /// 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 @@ public OpenIdConnectOptions(string authenticationScheme) 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 5f00cb18b..b71b8655b 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 006fafc73..000000000 --- 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 21c6189d7..eaf704bcb 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 @@ public class TwitterCreatingTicketContext : BaseTwitterContext /// 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 @@ public TwitterCreatingTicketContext( /// 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 033227542..2c8b30e9f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -8,9 +8,9 @@ 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 @@ public class TwitterEvents : RemoteAuthenticationEvents, ITwitterEvents 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 aa1da43ed..fe181fe7b 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 @@ public class TwitterRedirectToAuthorizationEndpointContext : BaseTwitterContext /// 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 @@ public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, Twitte /// 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 dc4bbf80a..c0b773345 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 df6ca1d02..2896365d6 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 000000000..b10435f18 --- /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 000000000..2170be902 --- /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 8481730a8..c166b175a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -8,13 +8,13 @@ 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 @@ internal class TwitterHandler : RemoteAuthenticationHandler 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 @@ protected virtual async Task CreateTicketAsync( 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 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext con { 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 @@ private async Task ObtainRequestTokenAsync(string callBackUri, Aut 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 @@ private async Task ObtainAccessTokenAsync(RequestToken token, strin 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 @@ private async Task RetrieveUserDetailsAsync(AccessToken accessToken, Cl 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 67fb903dd..000000000 --- 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 836dd3c0d..cf1bf4856 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -6,12 +6,13 @@ 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 @@ public class TwitterOptions : RemoteAuthenticationOptions /// public TwitterOptions() { - AuthenticationScheme = TwitterDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-twitter"); BackchannelTimeout = TimeSpan.FromSeconds(60); Events = new TwitterEvents(); @@ -55,16 +54,16 @@ public TwitterOptions() 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 000000000..771601ed1 --- /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 28f116d3d..000000000 --- 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 8e7e42765..083884a02 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 @@ protected HttpResponse Response get { return Context.Response; } } - protected PathString OriginalPathBase { get; private set; } + protected PathString OriginalPath => Context.Features.Get()?.OriginalPath ?? Request.Path; + + protected PathString OriginalPathBase => Context.Features.Get()?.OriginalPathBase ?? Request.PathBase; + + protected ILogger Logger { get; } - protected PathString OriginalPath { get; private set; } + protected UrlEncoder UrlEncoder { get; } - protected ILogger Logger { get; private set; } + protected ISystemClock Clock { get; } - protected UrlEncoder UrlEncoder { get; private set; } + protected IOptionsSnapshot OptionsSnapshot { get; } - public IAuthenticationHandler PriorHandler { get; set; } + /// + /// 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,193 +56,113 @@ protected string CurrentUri } } - 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) - { - return; - } - - if (InitializeResult?.Failure != null) + lock (Options.InitializeLock) { - 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; + } } } - } - - protected string BuildRedirectUri(string targetPath) - { - return Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; - } - private static async Task OnStartingCallback(object state) - { - var handler = (AuthenticationHandler)state; - await handler.FinishResponseOnce(); - } + Options.Validate(); - private async Task FinishResponseOnce() - { - if (!_finishCalled) - { - _finishCalled = true; - await FinishResponseAsync(); - await HandleAutomaticChallengeIfNeeded(); - } + await InitializeEventsAsync(); + await InitializeHandlerAsync(); } /// - /// Hook that is called when the response about to be sent + /// Initializes the events object, called once per request by . /// - /// - protected virtual Task FinishResponseAsync() + protected virtual async Task InitializeEventsAsync() { - return TaskCache.CompletedTask; - } - - private async Task HandleAutomaticChallengeIfNeeded() - { - if (!ChallengeCalled && Options.AutomaticChallenge && Response.StatusCode == 401) + Events = Options.Events; + if (Options.EventsType != null) { - await HandleUnauthorizedAsync(new ChallengeContext(Options.AuthenticationScheme)); + Events = Context.RequestServices.GetRequiredService(Options.EventsType); } + Events = Events ?? await CreateEventsAsync(); } /// - /// Called once after Invoke by AuthenticationMiddleware. + /// Creates a new instance of the events instance. /// - /// async completion - internal async Task TeardownAsync() - { - try - { - await FinishResponseOnce(); - } - finally - { - UnregisterAuthenticationHandler(); - } - } + /// A new instance of the events instance. + protected virtual Task CreateEventsAsync() => Task.FromResult(new object()); /// - /// 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. + /// Initializes the options, will be called only once by . /// - /// 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() + protected virtual void InitializeOptions() { - if (InitializeResult?.Handled == true) - { - return Task.FromResult(true); - } - return Task.FromResult(false); + // REVIEW: is there a better place for this default? + Options.DisplayName = Options.DisplayName ?? Scheme.Name; + Options.ClaimsIssuer = Options.ClaimsIssuer ?? Scheme.Name; } - public void GetDescriptions(DescribeSchemesContext describeContext) + /// + /// Called after options/events have been initialized for the handler to finish initializing itself. + /// + /// A task + protected virtual Task InitializeHandlerAsync() { - describeContext.Accept(Options.Description.Items); - - if (PriorHandler != null) - { - PriorHandler.GetDescriptions(describeContext); - } + return TaskCache.CompletedTask; } - public bool ShouldHandleScheme(string authenticationScheme, bool handleAutomatic) + protected string BuildRedirectUri(string targetPath) { - return string.Equals(Options.AuthenticationScheme, authenticationScheme, StringComparison.Ordinal) || - (handleAutomatic && string.Equals(authenticationScheme, AuthenticationManager.AutomaticScheme, StringComparison.Ordinal)); + return Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; } - public async Task AuthenticateAsync(AuthenticateContext context) + public async Task AuthenticateAsync() { - 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) { - // 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 @@ protected async Task HandleAuthenticateOnceSafeAsync() public async Task SignInAsync(SignInContext context) { - if (ShouldHandleScheme(context.AuthenticationScheme, handleAutomatic: false)) - { - SignInAccepted = true; - await HandleSignInAsync(context); - Logger.AuthenticationSchemeSignedIn(Options.AuthenticationScheme); - context.Accept(); - } - else if (PriorHandler != null) + if (context == 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 @@ public async Task SignOutAsync(SignOutContext context) 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 @@ protected virtual Task HandleSignOutAsync(SignOutContext context) /// 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 @@ protected virtual Task HandleForbiddenAsync(ChallengeContext context) /// 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) - { - 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(); - } - - if (!handled && PriorHandler != null) + switch (context.Behavior) { - await PriorHandler.ChallengeAsync(context); + 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; } } - - 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 a01490c3e..eba561d1d 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) - { - 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)) + if (schemes == null) { - // 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 + { + OriginalPath = context.Request.Path, + 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()) { - if (!await handler.HandleRequestAsync()) + var handler = await handlers.GetHandlerAsync(context, scheme.Name) as IAuthenticationRequestHandler; + if (handler != null && await handler.HandleRequestAsync()) { - await _next(context); + return; } } - finally + + var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync(); + if (defaultAuthenticate != null) { - try - { - await handler.TeardownAsync(); - } - catch (Exception) + var result = await context.AuthenticateAsync(defaultAuthenticate.Name); + if (result?.Principal != null) { - // Don't mask the original exception, if any + context.User = result.Principal; } } - } - protected abstract AuthenticationHandler CreateHandler(); + 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 34ec577f1..000000000 --- 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 000000000..09e7abbd4 --- /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 2aa320ae2..074f45b5f 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 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi 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 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi 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 1d56a8fb3..000000000 --- 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 6503f0bb8..000000000 --- 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 1edb4a0f4..000000000 --- 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 3c363ca98..000000000 --- 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 27965dbf4..000000000 --- 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 53f6a07a8..000000000 --- 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 70a76f27c..000000000 --- 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 db05db0e5..000000000 --- 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 10b3325d4..000000000 --- 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 4039a0560..fa582a304 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -34,10 +34,10 @@ public void HandleResponse() } /// - /// 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 @@ public void SkipToNextMiddleware() /// 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 @@ public bool CheckEventResult(out AuthenticateResult result) } 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 b11dec93f..dad4c40fe 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs @@ -11,7 +11,7 @@ public enum EventResultState 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 35af9cee3..5d2b30f13 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs @@ -7,7 +7,7 @@ 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 e2109a065..000000000 --- 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 6e7d6a35c..a130c1b14 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -7,7 +7,7 @@ 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 5d5fd4883..c0797ea9c 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 0d245cf0a..000000000 --- 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 cd42915c0..000000000 --- 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 316defc43..d4335f6d4 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 a6cf91046..11e2e4586 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 @@ internal static string FormatException_AuthenticationTokenDoesNotProvideSyncMeth 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 1e41fb0b5..fc663317e 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 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); - public override async Task HandleRequestAsync() + 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. + /// + protected new RemoteAuthenticationEvents Events + { + get { return (RemoteAuthenticationEvents)base.Events; } + set { base.Events = value; } + } + + protected RemoteAuthenticationHandler(IOptions sharedOptions, IOptionsSnapshot options, IDataProtectionProvider dataProtection, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { - if (Options.CallbackPath == Request.Path) + _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) { - return await HandleRemoteCallbackAsync(); + Options.SignInScheme = _authOptions.DefaultSignInScheme; } + } - return false; + public virtual Task ShouldHandleRequestAsync() + { + return Task.FromResult(Options.CallbackPath == Request.Path); } - protected virtual async Task HandleRemoteCallbackAsync() + 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 @@ protected virtual async Task HandleRemoteCallbackAsync() { return true; } - else if (authResult.Skipped) + else if (authResult.Nothing) { return false; } @@ -68,14 +113,13 @@ protected virtual async Task HandleRemoteCallbackAsync() { 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 @@ protected virtual async Task HandleRemoteCallbackAsync() } // 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 @@ protected virtual async Task HandleRemoteCallbackAsync() 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 @@ protected virtual async Task HandleRemoteCallbackAsync() 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) + { + 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)) { - 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 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 @@ protected override Task HandleSignInAsync(SignInContext context) 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 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties { 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 e990abd05..65cf6f2ec 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 @@ public class RemoteAuthenticationOptions : AuthenticationOptions /// 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 @@ public class RemoteAuthenticationOptions : AuthenticationOptions /// 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 77060045e..54d22bcc9 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 8b168c9a0..000000000 --- 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 e1c79192a..2320982ce 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 9f5c96cc1..000000000 --- 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 bb5700fc6..1564193b9 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 @@ public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app) } /// - /// 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 fade43716..000000000 --- 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 000000000..c4720eb30 --- /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 e6f881fef..55dd05426 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.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 @@ public async Task NormalRequestPassesThrough() [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 @@ public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() [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 @@ public async Task AjaxForbidTurnsInto403WithLocationHeader() [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 @@ public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() [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 @@ public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() 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 @@ public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri() 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 @@ public async Task SignInCausesDefaultCookieToBeCreated() [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 @@ public async Task SignInWrongAuthTypeThrows() [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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( 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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( [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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() [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 @@ public async Task CookieContainsIdentity() [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 @@ public async Task CookieAppliesClaimsTransform() [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 @@ public async Task CookieStopsWorkingAfterExpiration() [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 @@ public async Task CookieExpirationCanBeOverridenInSignin() [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 @@ public async Task ExpiredCookieWithValidatorStillExpired() [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"); @@ -441,26 +372,60 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name)); } + [Fact] + public async Task CookieNotRenewedAfterSignOut() + { + 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"); + + // 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 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"); @@ -469,19 +434,19 @@ public async Task CookieCanBeRenewedByValidator() 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 @@ public async Task CookieCanBeRenewedByValidator() [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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() 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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() [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 @@ public async Task CookieValidatorOnlyCalledOnce() 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 @@ public async Task CookieValidatorOnlyCalledOnce() [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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) [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 @@ public async Task CookieExpirationCanBeOverridenInEvent() 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 @@ public async Task CookieExpirationCanBeOverridenInEvent() [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 @@ public async Task CookieIsRenewedWithSlidingExpiration() 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 @@ public async Task CookieIsRenewedWithSlidingExpiration() [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 @@ public async Task CookieUsesPathBaseByDefault() 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 @@ public async Task CookieTurnsChallengeIntoForbidWithCookie(bool automatic) 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 @@ public async Task CookieChallengeRedirectsToLoginWithoutCookie(bool automatic) 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 @@ public async Task CookieForbidRedirectsWithoutCookie(bool automatic) [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 @@ public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() [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 @@ public async Task CookieChallengeRedirectsWithLoginPath() [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 @@ public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthentica 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 @@ public async Task MapWillNotAffectChallenge() 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 @@ public async Task ChallengeDoesNotSet401OnUnauthorized() } [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 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() 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 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() 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 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() 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 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() 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 @@ public async Task MapWillNotAffectAccessDenied() 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 @@ public async Task NestedMapWillNotAffectLogin() .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 @@ public async Task NestedMapWillNotAffectLogin() [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 @@ await context.Authentication.SignInAsync( [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 @@ await context.Authentication.SignInAsync( [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 @@ await context.Authentication.SignInAsync( [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 @@ public async Task NestedMapWillNotAffectAccessDenied() .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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ public async Task CanSpecifyAndShareDataProtector() public async Task NullExpiresUtcPropertyIsGuarded() { var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddAuthentication()) - .Configure(app => + .ConfigureServices(services => services.AddCookieAuthentication(o => { - app.UseCookieAuthentication(new CookieAuthenticationOptions + o.Events = new CookieAuthenticationEvents { - Events = new CookieAuthenticationEvents + OnValidatePrincipal = context => { - OnValidatePrincipal = context => - { - context.Properties.ExpiresUtc = null; - context.ShouldRenew = true; - return Task.FromResult(0); - } + context.Properties.ExpiresUtc = null; + context.ShouldRenew = true; + return Task.FromResult(0); } - }); + }; + })) + .Configure(app => + { + 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 @@ private static async Task GetAuthData(TestServer server, string url, s 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 @@ private static TestServer CreateServer(CookieAuthenticationOptions options, Func { 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 @@ private static TestServer CreateServer(CookieAuthenticationOptions options, Func } }); }) - .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 000000000..a152c735b --- /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 4d6cabaf1..79066e48b 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.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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() [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 @@ public async Task MapWillNotAffectRedirect() var server = CreateServer( app => { - app.UseFacebookAuthentication(new FacebookOptions + app.UseAuthentication(); + app.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); + }, + services => + { + services.AddCookieAuthentication("External", o => { }); + services.AddFacebookAuthentication(o => { - AppId = "Test App Id", - AppSecret = "Test App Secret", - SignInScheme = "External" + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.SignInScheme = "External"; }); - app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); }, - 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 @@ public async Task MapWillNotAffectRedirect() public async Task ChallengeWillTriggerRedirection() { var server = CreateServer( - app => + app => app.UseAuthentication(), + services => { - app.UseFacebookAuthentication(new FacebookOptions + services.AddAuthentication(options => { - AppId = "Test App Id", - AppSecret = "Test App Secret" + options.DefaultSignInScheme = "External"; }); - app.UseCookieAuthentication(new CookieAuthenticationOptions + services.AddCookieAuthentication(); + services.AddFacebookAuthentication(o => { - AuthenticationScheme = "External" + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; }); }, - 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"); @@ -168,14 +268,23 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() } 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 @@ private static TestServer CreateServer(Action configure, Ac 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 090f9f121..77ddcc7ef 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.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 @@ public async Task ChallengeWillTriggerRedirection() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task ChallengeWillSetDefaultScope() 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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() 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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() [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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() [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 @@ public async Task AuthenticateWithoutCookieWillFail() 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 @@ public async Task AuthenticateWithoutCookieWillFail() [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 @@ public async Task ReplyPathWithoutStateQueryStringWillBeRejected() [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 @@ public async Task ReplyPathWithErrorFails(bool redirect) 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 @@ public async Task ReplyPathWithErrorFails(bool redirect) 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 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - } + }; }); var properties = new AuthenticationProperties(); @@ -385,20 +410,20 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla 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 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) ctx.HandleResponse(); return Task.FromResult(0); } - } : new OAuthEvents() + } : new OAuthEvents(); }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -438,19 +463,19 @@ public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) 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 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) ctx.HandleResponse(); return Task.FromResult(0); } - } : new OAuthEvents() + } : new OAuthEvents(); }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -487,12 +512,12 @@ public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }, - Events = new OAuthEvents + }; + o.Events = new OAuthEvents { OnCreatingTicket = context => { @@ -540,7 +565,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() 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 @@ public async Task ValidateAuthenticatedContext() 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 @@ public async Task ValidateAuthenticatedContext() throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - } + }; }); var properties = new AuthenticationProperties(); @@ -723,10 +748,10 @@ public async Task ValidateAuthenticatedContext() [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 @@ public async Task NoStateCausesException() 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 @@ public async Task CanRedirectOnError() ctx.HandleResponse(); return Task.FromResult(0); } - } + }; }); //Post a message to the Google middleware @@ -766,13 +791,13 @@ public async Task CanRedirectOnError() 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 @@ public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() 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 @@ public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() 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 @@ public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() 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 @@ public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() 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 @@ private static HttpResponseMessage ReturnJsonResponse(object content, HttpStatus 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 @@ private static TestServer CreateServer(GoogleOptions options, Func(() => 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 @@ private static TestServer CreateServer(GoogleOptions options, Func { - 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 c0d2ddba5..08098622c 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 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 @@ public async Task BearerTokenValidation() [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 @@ public async Task SignInThrows() [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 @@ public async Task SignOutThrows() [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 @@ public async Task ThrowAtAuthenticationFailedEvent() 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 @@ public async Task ThrowAtAuthenticationFailedEvent() [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 @@ public async Task CustomHeaderReceived() }; 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 @@ public async Task CustomHeaderReceived() [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 @@ public async Task NoHeaderReceived() [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 @@ public async Task HeaderWithoutBearerReceived() [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 @@ public async Task UnrecognizedTokenReceived() [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 @@ public async Task InvalidTokenReceived() [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 @@ public async Task ExceptionReportedInHeaderForAuthenticationFailures(Type errorT [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 @@ public async Task ExceptionNotReportedInHeaderForOtherFailures(Type errorType) [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 @@ public async Task ExceptionsReportedInHeaderForMultipleAuthenticationFailures() [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 @@ public async Task ExceptionsReportedInHeaderExposesUserDefinedError(string error 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 @@ public async Task ExceptionsReportedInHeaderExposesUserDefinedError(string error [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 @@ public async Task ExceptionNotReportedInHeaderWhenIncludeErrorDetailsIsFalse() [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 @@ public async Task ExceptionNotReportedInHeaderWhenTokenWasMissing() [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 @@ public async Task CustomTokenValidated() 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 @@ public async Task CustomTokenValidated() [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 @@ public async Task RetrievingTokenFromAlternateLocation() [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 @@ public async Task BearerTurns401To403IfAuthenticated() [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 @@ public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() { throw new NotImplementedException(); }, - } + }; }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -432,9 +486,9 @@ public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() { throw new NotImplementedException(); }, - } + }; }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -463,15 +517,15 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() } [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 @@ public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() { 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 @@ public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() { 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 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() } [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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() }, 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 @@ public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() [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 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() { 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 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() } [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 @@ public async Task EventOnChallengeSkipped_ResponseNotModified() 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 @@ public async Task EventOnChallengeHandled_ResponseNotModified() context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, - } + }; }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -699,10 +750,7 @@ public int MaximumTokenSizeInBytes 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 @@ public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParame } } - 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 @@ private static TestServer CreateServer(JwtBearerOptions options, Func { 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 @@ private static TestServer CreateServer(JwtBearerOptions options, Func(() => 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 @@ private static TestServer CreateServer(JwtBearerOptions options, Func 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 bbf54ec5e..801567d7e 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 0ed164e49..000000000 --- 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 000000000..26110e9fe --- /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 000000000..95c086c80 --- /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 432980f77..5614fe8fe 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 1912561b1..3c0146b08 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.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 @@ public class OpenIdConnectChallengeTests 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 @@ public async Task ChallengeIsIssuedCorrectly() [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 @@ Example of a form post */ [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 @@ public async Task ChallengeIssuedCorrectlyForFormPost() [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 @@ public async Task ChallengeCanSetUserStateThroughProperties(string userState) 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 @@ public async Task ChallengeCanSetUserStateThroughProperties(string userState) [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 @@ public async Task OnRedirectToIdentityProviderEventCanSetState(string userState) 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 @@ public async Task OnRedirectToIdentityProviderEventIsHit() var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -203,12 +232,13 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceValues() 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 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceMessage() var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -268,12 +300,15 @@ public async Task OnRedirectToIdentityProviderEventCanReplaceMessage() // 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 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() 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 @@ public async Task OnRedirectToIdentityProviderEventSkipResponse() [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 @@ public async Task ChallengeSetsNonceAndStateCookies() 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 0f5338c5c..3ceb4a533 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 a212af649..607e9bb62 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -40,7 +40,7 @@ public class OpenIdConnectEventTests 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 @@ public async Task OnMessageReceived_Skipped_NoMoreEventsRun() OnMessageReceived = context => { messageReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTokenValidated = TokenNotImpl, @@ -110,7 +110,7 @@ public async Task OnMessageReceived_Handled_NoMoreEventsRun() } [Fact] - public async Task OnTokenValidated_Skipped_NoMoreEventsRun() + public async Task OnTokenValidated_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -124,7 +124,7 @@ public async Task OnTokenValidated_Skipped_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -242,7 +242,7 @@ public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() } [Fact] - public async Task OnAuthorizationCodeReceived_Skipped_NoMoreEventsRun() + public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -262,7 +262,7 @@ public async Task OnAuthorizationCodeReceived_Skipped_NoMoreEventsRun() OnAuthorizationCodeReceived = context => { codeReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -391,7 +391,7 @@ public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketRece } [Fact] - public async Task OnTokenResponseReceived_Skipped_NoMoreEventsRun() + public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -417,7 +417,7 @@ public async Task OnTokenResponseReceived_Skipped_NoMoreEventsRun() OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -558,7 +558,7 @@ public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived } [Fact] - public async Task OnTokenValidatedBackchannel_Skipped_NoMoreEventsRun() + public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() { var messageReceived = false; var codeReceived = false; @@ -584,7 +584,7 @@ public async Task OnTokenValidatedBackchannel_Skipped_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -725,7 +725,7 @@ public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketRece } [Fact] - public async Task OnUserInformationReceived_Skipped_NoMoreEventsRun() + public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -757,7 +757,7 @@ public async Task OnUserInformationReceived_Skipped_NoMoreEventsRun() OnUserInformationReceived = context => { userInfoReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -910,7 +910,7 @@ public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceiv } [Fact] - public async Task OnAuthenticationFailed_Skipped_NoMoreEventsRun() + public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -949,7 +949,7 @@ public async Task OnAuthenticationFailed_Skipped_NoMoreEventsRun() { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -1093,8 +1093,8 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( }; 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 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( } [Fact] - public async Task OnRemoteFailure_Skipped_NoMoreEventsRun() + public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1174,7 +1174,7 @@ public async Task OnRemoteFailure_Skipped_NoMoreEventsRun() { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTicketReceived = TicketNotImpl, @@ -1274,7 +1274,7 @@ public async Task OnRemoteFailure_Handled_NoMoreEventsRun() } [Fact] - public async Task OnTicketReceived_Skipped_NoMoreEventsRun() + public async Task OnTicketReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1314,7 +1314,7 @@ public async Task OnTicketReceived_Skipped_NoMoreEventsRun() OnTicketReceived = context => { ticektReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, @@ -1408,27 +1408,27 @@ private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appC 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 a58d54b65..a3d7f5130 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 @@ public class OpenIdConnectMiddlewareTests 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 @@ public async Task SignOutSettingMessage() { 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 @@ public async Task SignOutSettingMessage() [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 @@ public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled 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 @@ public async Task SignOutWithDefaultRedirectUri() 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 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 5a672093e..aa7f6179b 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.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 @@ public static OpenIdConnectOptions CreateOpenIdConnectOptions() => public static OpenIdConnectOptions CreateOpenIdConnectOptions(Action update) { var options = CreateOpenIdConnectOptions(); - - if (update != null) - { - update(options); - } - + update?.Invoke(options); return options; } @@ -58,26 +52,20 @@ public static OpenIdConnectConfiguration CreateDefaultOpenIdConnectConfiguration 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 @@ public static TestServer CreateServer( 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 @@ public static TestServer CreateServer( } 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 @@ await context.Authentication.SignOutAsync( }) .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 a7085966a..609aed6f6 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.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 a3bea3ebe..9d9e5537f 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.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 @@ public TestSettings() : this(configure: null) public TestSettings(Action configure) { - _options = TestServerBuilder.CreateOpenIdConnectOptions(configure); - } - - public TestSettings(OpenIdConnectOptions options) - { - _options = options; + _configureOptions = o => + { + configure?.Invoke(o); + _options = o; + }; } - 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 @@ private void ValidateParameters( } } + OpenIdConnectOptions _options = null; + private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) { string expectedAuthority; @@ -212,8 +211,7 @@ private void ValidateSkuTelemetry(IDictionary actualQuery, IColl 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 @@ private void ValidateQueryParameter( } } } -} +} \ 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 745c41350..4f924172c 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.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 028cf6760..fb7ea3443 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 @@ public void UpdateTokenValueReturnsFalseForUnknownToken() } - 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")); - } + //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.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 2ca2223b9..000000000 --- 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 000000000..432227aed --- /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 d9065add3..c964221fb 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 729c01630..d2736ca0d 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 34d967617..e45c7f690 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -5,6 +5,7 @@ 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 @@ public async Task CookiePolicyAppliesToCookieAuth() 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 @@ public async Task CookiePolicyAppliesToCookieAuth() 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 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() 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 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() 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 b9155b4df..a972731ea 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 79288b026..a06624fac 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -13,6 +13,8 @@ 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 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() 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 @@ public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithLargeNewCookieContainsIdentity() 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 7b2d261bb..b14ea0d74 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -58,7 +58,7 @@ public void InteropSerializerCanReadNewTicket() 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 353/611] 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 3f2f0ee8d..a7da8e72c 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 89e7ef9c3..9d6c49442 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 c0e7569ac..73b5140ed 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 a5e4c8b0c..773bc41d6 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 c0b773345..3d13a3d07 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 354/611] 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 d4335f6d4..07936ed25 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 355/611] 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 a06624fac..ae5e6f018 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -35,7 +35,7 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithLargeNewCookieContainsIdentity() 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 356/611] 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 3f64d813d..7c1dd9d8d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -238,7 +238,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) 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 bcfa95c0a..79d9ac66c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddFacebookAuthentication(this IServiceCollecti 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 d85e3a2d6..420d14030 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddGoogleAuthentication(this IServiceCollection 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 1f8884ab2..509016ff2 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddMicrosoftAccountAuthentication(this IService 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 aa7c59f03..6fd0f57f4 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 89581b201..64737a9ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol 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 2170be902..1e126d4c4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio 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 074f45b5f..0315562ff 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -45,7 +45,7 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi 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 @@ public static IServiceCollection AddScheme(this IServiceColl { o.AddScheme(authenticationScheme, scheme => { scheme.HandlerType = typeof(THandler); + scheme.DisplayName = displayName; configureScheme?.Invoke(scheme); }); }); @@ -67,6 +68,11 @@ public static IServiceCollection AddScheme(this IServiceColl 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 55dd05426..419d82493 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -26,6 +26,18 @@ public class CookieTests { 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 a152c735b..d239d85f8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -99,7 +99,7 @@ private static TestServer CreateServer(Action configureAu { 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 79066e48b..edd9eb578 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 77ddcc7ef..0ab3e4493 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 08098622c..42efe00dd 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 26110e9fe..1f0f394f3 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 95c086c80..dd48f7c95 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 432227aed..9993559f6 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 357/611] 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 358/611] 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 a37c3659d..65d0ef740 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 74661c2f3..41bf8c0ef 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 359/611] 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 9c5464a54..3f55ba5b3 100644 --- a/build/common.props +++ b/build/common.props @@ -17,7 +17,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index b9ac0f5f0..2c8cbafc5 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 360/611] 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 93f1ac47d..fa4304af9 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 5bf0e2c11..225b1fe45 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 b0bcadb57..702b25c63 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 2c8cbafc5..5d7f9bb68 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 361/611] Updating package version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 44cb2290b..0b2b8e001 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 362/611] 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 65d0ef740..a37c3659d 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 41bf8c0ef..74661c2f3 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 363/611] 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 5d7f9bb68..77c4b3d71 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 364/611] 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 81d0cc4b9..157849c91 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 77c4b3d71..5203ebced 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 d4bab3eeb..396aed1f5 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 9fd7e9412..27fa4ca17 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 e4a42b8c4..2a838df7e 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 1f9310329..86b04d587 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 65d0ef740..274fe9afa 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 41bf8c0ef..152072898 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 fe63ab5ca..e0336cc0e 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 a7da8e72c..a5728fbab 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 56e48d3fe..000000000 --- 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 8f46ff169..19ec83413 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 1e070fc7f..000000000 --- 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 7b6c9ee5d..e403fe4a9 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 647633afa..000000000 --- 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 9d6c49442..05bdd4131 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 37e18e53e..000000000 --- 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 5b8263c9c..4d91e0da1 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 06b3cd0d5..000000000 --- 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 73b5140ed..5fb75ead9 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 d485aedb1..000000000 --- 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 773bc41d6..aab8833d2 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 64cb79487..000000000 --- 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 3d13a3d07..5dd58d680 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 c35232a31..000000000 --- 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 07936ed25..54b560702 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 1f69da5a8..000000000 --- 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 0382fd2b5..bc5b7be91 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 8ae585270..000000000 --- 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 146917cab..31ce5b761 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 8eef347eb..000000000 --- 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 f1a07c5bf..000000000 --- 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 6a1019fbc..000000000 --- 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 b323258d9..000000000 --- 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 1e75761b7..000000000 --- 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 731358894..000000000 --- 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 1a6679119..000000000 --- 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 490fa7cb2..000000000 --- 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 1fc242ec5..000000000 --- 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 801567d7e..df51faf88 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 c964221fb..a2d4a61de 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 d2736ca0d..6ca53f519 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 a972731ea..ca850d754 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 ae5e6f018..000000000 --- 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 02763b93f..000000000 --- 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 b14ea0d74..000000000 --- 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 365/611] 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 7deed359e..3f40d3194 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 @@ 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() diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 0480556f6..3aebb419f 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSample { @@ -17,10 +16,8 @@ public void ConfigureServices(IServiceCollection services) 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 adf8f1f1a..1a19850e6 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 @@ 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() diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index ca21070dc..9ad9e6841 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSessionSample { @@ -18,10 +17,8 @@ public void ConfigureServices(IServiceCollection services) 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 11d1fbeaf..9de0185a4 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 @@ 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() diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 19bb0ac6a..ebb59c060 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -12,7 +12,6 @@ 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 @@ public void ConfigureServices(IServiceCollection services) }); } - 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 741dd6ebf..b4d24505d 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; namespace OpenIdConnectSample { @@ -13,6 +14,13 @@ public static 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 => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 5faa48b52..af1406289 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -11,7 +11,6 @@ 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 @@ public void ConfigureServices(IServiceCollection services) }); } - 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 76fb5e59a..96bce512d 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -4,8 +4,8 @@ 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 @@ 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(options => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 7c1dd9d8d..22c44b3ea 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -16,7 +16,6 @@ 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 @@ public void ConfigureServices(IServiceCollection services) }); } - 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 366/611] 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 8dbb18b6c..955457fe8 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 05bdd4131..c2b99e47d 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 5fb75ead9..8e33372c1 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 aab8833d2..b3829b59d 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 bc5b7be91..b39a7bf3d 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 ca850d754..34224e21f 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 367/611] Add auth link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab822bd68..e8e64c293 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 368/611] 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 955457fe8..74d501f7c 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 0ab3e4493..68ea33462 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -405,7 +405,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla 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 @@ public async Task ValidateAuthenticatedContext() 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 @@ public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() 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 @@ private static TestServer CreateServer(Action configureOptions, F } 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 df51faf88..98d727fde 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 dd48f7c95..2381fd6cd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -73,6 +73,7 @@ public async Task ThrowsIfClientSecretMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( @@ -118,6 +119,7 @@ public async Task ThrowsIfTokenEndpointMissing() 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 8eeedde0d..41429cd37 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -78,7 +78,7 @@ public void CanRoundTripActorIdentity() 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 @@ public void CanRoundTripClaimProperties() 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 fb7ea3443..afdef0a40 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -45,9 +45,9 @@ public void SubsequentStoreTokenDeletesPreviousTokens() 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 7b0fc8c8b..246eed9a5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -106,6 +106,7 @@ public async Task Authorize_ShouldAllowIfClaimIsAmongValues() Assert.True(allowed); } + [Fact] public async Task Authorize_ShouldInvokeAllHandlersByDefault() { // Arrange @@ -1152,4 +1153,4 @@ public async Task CanUseCustomContextThatAlwaysFails() } } -} \ 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 a2d4a61de..a9ba71a79 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 6ca53f519..7908e98fc 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 34224e21f..b7b2c6afe 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 369/611] 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 22c44b3ea..ffffa4646 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -75,7 +75,6 @@ public void ConfigureServices(IServiceCollection services) // 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 @@ public void ConfigureServices(IServiceCollection services) // 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 @@ public void ConfigureServices(IServiceCollection services) // 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 @@ public void ConfigureServices(IServiceCollection services) // 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 017e7911c..5a4ffc547 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -59,39 +59,6 @@ protected override Task InitializeHandlerAsync() /// 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 000000000..af4a85b19 --- /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 56d6ca238..9b6b51d8e 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 @@ public string CookieName 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 @@ public string CookieName /// /// 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 e8a21d01b..b528dec9c 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 @@ public static class CookieExtensions 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 79d9ac66c..032be8235 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddFacebookAuthentication(this IServiceCollecti 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 521684d14..c94048f9b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -9,7 +9,6 @@ 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 420d14030..d71e8b461 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddGoogleAuthentication(this IServiceCollection 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 c699f5cc9..3a93c5cbf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -9,7 +9,6 @@ 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 77ffd76ff..4f6453bd9 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 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect 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 2ea03a51f..ec48e3e20 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -40,49 +40,6 @@ public JwtBearerHandler(IOptionsSnapshot options, ILoggerFacto 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 000000000..0aeed1183 --- /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 509016ff2..6ccb39234 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddMicrosoftAccountAuthentication(this IService 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 b2b787b97..815b94bf4 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -7,7 +7,6 @@ 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 f50dff3f5..6e3105639 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -170,7 +170,7 @@ public void RunClaimActions(JObject userData) 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 6fd0f57f4..408789b03 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 cafc4f0bc..63bcdbdf2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -10,7 +10,6 @@ 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 000000000..99f65253a --- /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 64737a9ad..c79dc7212 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 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol 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 69acbf9a0..d51c324dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,12 +13,10 @@ 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 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler 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 @@ public OpenIdConnectHandler(IOptions sharedOptions, IOpti 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private OpenIdConnectProtocolException CreateOpenIdConnectProtocolException(Open 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 000000000..7421af9c0 --- /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 5ca270dde..b2d69d524 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -39,7 +39,6 @@ public class OpenIdConnectOptions : RemoteAuthenticationOptions /// 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 1e126d4c4..3bcc80c3d 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 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio 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 c166b175a..7ae9f973c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -40,36 +40,12 @@ internal class TwitterHandler : RemoteAuthenticationHandler 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected virtual async Task CreateTicketAsync( { 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 000000000..08e9c5b83 --- /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 083884a02..ba1c919fe 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -48,6 +48,8 @@ protected HttpResponse Response /// protected virtual object Events { get; set; } + protected virtual string ClaimsIssuer => Options.ClaimsIssuer ?? Scheme.Name; + protected string CurrentUri { get @@ -85,18 +87,6 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte 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 @@ protected virtual async Task InitializeEventsAsync() /// 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 09e7abbd4..55bc09d8a 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 @@ 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 /// @@ -36,15 +40,5 @@ public virtual void Validate() /// 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 0315562ff..ff367f555 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -74,5 +74,30 @@ public static IServiceCollection AddScheme(this IServiceColl 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 fc663317e..bf875a7a0 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,9 +5,7 @@ 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 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand 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 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand 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 @@ 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); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index edd9eb578..060eb649f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -50,7 +50,6 @@ public void AddCanBindAgainstDefaultConfig() {"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 @@ public void AddCanBindAgainstDefaultConfig() 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 68ea33462..2c86bc778 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -49,7 +49,6 @@ public void AddCanBindAgainstDefaultConfig() {"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 @@ public void AddCanBindAgainstDefaultConfig() 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 42efe00dd..59f1e880c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -48,11 +48,10 @@ public void AddCanBindAgainstDefaultConfig() {"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 @@ public void AddCanBindAgainstDefaultConfig() 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 1f0f394f3..062215ff4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -50,7 +50,6 @@ public void AddCanBindAgainstDefaultConfig() {"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 @@ public void AddCanBindAgainstDefaultConfig() 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 a3d7f5130..b2459cf81 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -36,6 +36,7 @@ public void AddCanBindAgainstDefaultConfig() { {"OpenIdConnect:ClientId", ""}, {"OpenIdConnect:ClientSecret", ""}, + {"OpenIdConnect:RequireHttpsMetadata", "false"}, {"OpenIdConnect:Authority", ""} }; var configurationBuilder = new ConfigurationBuilder(); @@ -48,6 +49,7 @@ public void AddCanBindAgainstDefaultConfig() 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 9993559f6..1acddc5af 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -42,7 +42,6 @@ public void AddCanBindAgainstDefaultConfig() {"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 @@ public void AddCanBindAgainstDefaultConfig() 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 370/611] 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 3aebb419f..79d1b3c3f 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -13,6 +13,13 @@ public class Startup { 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 9ad9e6841..c35dfd999 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -14,6 +14,13 @@ public class Startup { 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 9df41a9ab..030e640c9 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -43,6 +43,13 @@ public Startup(IHostingEnvironment env) // 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 e69563ced..875762d12 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 b4d24505d..87e775508 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -23,16 +23,12 @@ public static void Main(string[] args) }) .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 96bce512d..a712b6c03 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -21,16 +21,12 @@ public static void Main(string[] args) }) .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 e0336cc0e..723d74de3 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 ffffa4646..003972009 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -164,11 +164,6 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 408789b03..257aed9cb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -12,7 +12,7 @@ public static class OAuthExtensions { 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 371/611] 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 16426507c..9b602383c 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -33,7 +33,7 @@ internal class ChunkingCookieManager /// /// 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 @@ 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'. + // Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'. ChunkSize = DefaultChunkSize; ThrowForPartialCookies = true; } @@ -166,6 +166,7 @@ public void AppendResponseCookie(HttpContext context, string key, string value, { 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) { Path = options.Path, Domain = options.Domain, + SameSite = options.SameSite, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); @@ -297,6 +299,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) { 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 5a4ffc547..13a20e55b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -179,6 +179,7 @@ private CookieOptions BuildCookieOptions() 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 9b6b51d8e..02d0361b7 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 @@ public CookieAuthenticationOptions() ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; + CookieSameSite = SameSiteMode.Strict; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); @@ -57,6 +57,12 @@ public string CookieName /// 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 d51c324dc..04359142a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -899,6 +899,7 @@ private void WriteNonceCookie(string nonce) new CookieOptions { HttpOnly = true, + SameSite = Http.SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); @@ -930,6 +931,7 @@ private string ReadNonceCookie(string nonce) 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 7ae9f973c..ff054d3c6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -83,6 +83,7 @@ protected override async Task HandleRemoteAuthenticateAsync( var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps }; @@ -160,6 +161,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext context) 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 bf875a7a0..a7de95dfe 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -203,6 +203,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; @@ -242,6 +243,7 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 46daaad81..92adac967 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -74,7 +74,7 @@ public IResponseCookies Cookies 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 @@ private void ApplyPolicy(CookieOptions options) 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 @@ private void ApplyPolicy(CookieOptions options) 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 6aed18bfb..7203e73e6 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 419d82493..e38dc1587 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -136,6 +136,7 @@ public async Task SignInCausesDefaultCookieToBeCreated() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 c978d169e..143e1d254 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -18,7 +18,7 @@ public void AppendLargeCookie_Appended() 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 @@ public void AppendLargeCookieWithLimit_Chunked() 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 @@ public void DeleteChunkedCookieWithOptions_AllDeleted() 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 e45c7f690..737c12dc3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -36,6 +36,15 @@ public class CookiePolicyTests 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 @@ await RunTest("/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]); + 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 @@ await RunTest("/secureNone", 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 @@ await RunTest("/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]); + 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 @@ await RunTest("/httpOnlyAlways", 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 @@ await RunTest("/httpOnlyNone", 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 @@ public async Task CookiePolicyCanHijackAppend() 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 @@ public async Task CookiePolicyCanHijackDelete() 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 372/611] 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 157849c91..b9e6ac567 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 3f55ba5b3..dc4ad9a78 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index 74d501f7c..f7e538a50 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 396aed1f5..d4bab3eeb 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 27fa4ca17..d251b844e 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 2a838df7e..a2d0490f1 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 86b04d587..c2f73fd96 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 78ba03c2a..785724908 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 875762d12..03384f567 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 723d74de3..999dc91a6 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 a5728fbab..41c4ff790 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 19ec83413..e39b31e90 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 e403fe4a9..c4f1e7ad8 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 c2b99e47d..5b25e00e8 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 4d91e0da1..1a954c850 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 8e33372c1..508c815fe 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 b3829b59d..0ce2fe34e 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 5dd58d680..b78de6597 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 54b560702..cbdb05b58 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 b39a7bf3d..93673ef00 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 31ce5b761..5dc2cd928 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 000000000..f1a07c5bf --- /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 000000000..6a1019fbc --- /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 000000000..b323258d9 --- /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 000000000..1e75761b7 --- /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 000000000..731358894 --- /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 000000000..10a8be30f --- /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 000000000..490fa7cb2 --- /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 000000000..1fc242ec5 --- /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 98d727fde..c44069f43 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 a9ba71a79..48b134740 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 7908e98fc..b578f5dcf 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 b7b2c6afe..f513de4b3 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 000000000..ae5e6f018 --- /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 000000000..d6e9d16e5 --- /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 000000000..b14ea0d74 --- /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 373/611] 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 b9e6ac567..61ea7b0c3 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 13a20e55b..bb2c10fee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -247,7 +247,7 @@ protected virtual async Task FinishResponseAsync() } } - protected override async Task HandleSignInAsync(SignInContext signin) + protected override async Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { _signInCalled = true; @@ -259,8 +259,8 @@ protected override async Task HandleSignInAsync(SignInContext signin) Context, Scheme, Options, - signin.Principal, - signin.Properties, + user, + properties, cookieOptions); DateTimeOffset issuedUtc; @@ -325,7 +325,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signOutContext) Context, Scheme, Options, - signOutContext.Properties, + properties, cookieOptions); await Events.SigningOut(context); @@ -401,9 +401,8 @@ private static bool IsHostRelative(string path) 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 @@ protected override async Task HandleForbiddenAsync(ChallengeContext context) 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 9305623da..887789ebf 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 032be8235..1bb065414 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 e19c1fdb1..1041f1eec 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 d71e8b461..c11b155d9 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 f3571a49c..d26bf6671 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 4f6453bd9..0bd3a9400 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -5,22 +5,14 @@ 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 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect 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 ec48e3e20..0087d38d0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -201,10 +201,10 @@ protected override async Task HandleAuthenticateAsync() } } - 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 @@ private static string CreateErrorDescription(Exception authFailure) 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 520c3758d..b0be3de97 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 6ccb39234..1a7fee370 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 63bcdbdf2..bbe4f4038 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -191,14 +191,8 @@ protected virtual async Task CreateTicketAsync(ClaimsIdent 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 9afae436d..1a6450b7b 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 c79dc7212..b4ac4b9fb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -5,22 +5,14 @@ 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 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol 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 04359142a..9c8f4ecc6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -161,7 +161,7 @@ protected virtual async Task HandleRemoteSignOutAsync() /// 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 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) }; // Get the post redirect URI. - var properties = signout.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); @@ -292,19 +291,13 @@ protected virtual Task HandleSignOutCallbackAsync() /// 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 b10435f18..03d7ae809 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 3bcc80c3d..11586f984 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -5,22 +5,14 @@ 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 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio 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 ff054d3c6..63a18e83b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -140,15 +140,8 @@ protected virtual async Task CreateTicketAsync( 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 ba1c919fe..b09470919 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 @@ protected async Task HandleAuthenticateOnceSafeAsync() 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 @@ protected virtual Task HandleForbiddenAsync(ChallengeContext context) /// 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 000000000..cfe5809c5 --- /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 000000000..3d65f0dd7 --- /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 a7de95dfe..9394b7553 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 @@ protected override async Task HandleAuthenticateAsync() 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 000000000..1717a0ae0 --- /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 000000000..5123b7069 --- /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 000000000..d7d481dcd --- /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 000000000..60f291f67 --- /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 000000000..9b72a5cab --- /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 000000000..89956c9aa --- /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 5cba0fd9e..36e0ca7c3 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -143,7 +143,7 @@ public static async Task CombineAsync(IAuthorizationPolicyP 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 000000000..46dca35fb --- /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 a9961b69e..c089fba28 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -27,6 +27,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic 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 3b78c952e..c12815232 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -24,7 +24,7 @@ public static class AuthorizationServiceExtensions /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// 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 c911dc56b..63bfa30d4 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -25,13 +25,29 @@ public AuthorizeAttribute(string policy) 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 64cc695b8..4bbc283be 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 000000000..d297d4cdc --- /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 8980d51ac..3380f64b1 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 @@ public class DefaultAuthorizationService : IAuthorizationService { 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 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, } _options = options.Value; - _handlers = handlers.ToArray(); + _handlers = handlers; _policyProvider = policyProvider; _logger = logger; _evaluator = evaluator; @@ -86,7 +77,7 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, /// 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 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE } 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 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE } } - 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 @@ private static string GetClaimValue(IIdentity identity, string claimsType) /// 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 7b2c5d1bc..baa6f828c 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 000000000..7f0d9f5d3 --- /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 a130c84b0..32af74607 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -29,7 +29,7 @@ public interface IAuthorizationService /// 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 @@ public interface IAuthorizationService /// 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 b48449b5c..1196db82d 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -21,6 +21,6 @@ public interface IAuthorizeData /// /// 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 c4720eb30..b09f13cab 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 @@ public Task AuthenticateAsync() 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 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) 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 @@ public Task AuthenticateAsync() 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 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) 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 @@ public Task AuthenticateAsync() 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 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) 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 e38dc1587..677120e4b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -702,22 +702,6 @@ public async Task CookieUsesPathBaseByDefault() 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 @@ public async Task CookieForbidRedirectsWithoutCookie() 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 @@ public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthentica public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) { var builder = new WebHostBuilder() - .Configure(app => { + .Configure(app => + { if (useAuth) { app.UseAuthentication(); @@ -1296,7 +1262,7 @@ private static TestServer CreateServerWithServices(Action co } 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 060eb649f..657c957bf 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,6 +20,7 @@ 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 @@ public void AddCanBindAgainstDefaultConfig() { 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 2c86bc778..b316e6275 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,6 +19,7 @@ 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 @@ public void AddCanBindAgainstDefaultConfig() { 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 @@ public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() 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 59f1e880c..6746f5c3f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,6 +19,7 @@ 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 @@ public void AddCanBindAgainstDefaultConfig() { 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 @@ public void AddCanBindAgainstDefaultConfig() } [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 @@ public async Task RetrievingTokenFromAlternateLocation() 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 062215ff4..0d49052f5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,6 +20,7 @@ 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 @@ public void AddCanBindAgainstDefaultConfig() { 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 b2459cf81..9dc597b85 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.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 @@ public void AddCanBindAgainstDefaultConfig() { 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 41429cd37..b37ae53d5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -5,7 +5,7 @@ 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 1acddc5af..b8af66cdf 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,6 +14,7 @@ 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 @@ public void AddCanBindAgainstDefaultConfig() { 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 6825dd868..714b26c7e 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -25,9 +25,9 @@ public async Task CanCombineAuthorizeAttributes() // 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 @@ public async Task CanReplaceDefaultPolicy() // 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 @@ public async Task CombineMustTrimAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , a2" } + new AuthorizeAttribute() { AuthenticationSchemes = "a1 , a2" } }; var options = new AuthorizationOptions(); @@ -120,7 +120,7 @@ public async Task CombineMustIgnoreEmptyAuthenticationScheme() { // 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 246eed9a5..ef17b9462 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -53,7 +53,7 @@ public async Task Authorize_ShouldAllowIfClaimIsPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -76,7 +76,7 @@ public async Task Authorize_ShouldAllowIfClaimIsPresentWithSpecifiedAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -103,7 +103,7 @@ public async Task Authorize_ShouldAllowIfClaimIsAmongValues() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -126,7 +126,8 @@ public async Task Authorize_ShouldInvokeAllHandlersByDefault() 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 @@ public async Task Authorize_ShouldInvokeAllHandlersDependingOnSetting(bool invok 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 @@ public Task HandleAsync(AuthorizationHandlerContext context) } } - - [Fact] public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() { @@ -196,7 +195,8 @@ public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() 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 @@ public async Task Authorize_ShouldNotAllowIfClaimTypeIsNotPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -248,7 +248,7 @@ public async Task Authorize_ShouldNotAllowIfClaimValueIsNotPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -272,7 +272,7 @@ public async Task Authorize_ShouldNotAllowIfNoClaims() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -291,7 +291,7 @@ public async Task Authorize_ShouldNotAllowIfUserIsNull() var allowed = await authorizationService.AuthorizeAsync(null, null, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -311,7 +311,7 @@ public async Task Authorize_ShouldNotAllowIfNotCorrectAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -337,7 +337,7 @@ public async Task Authorize_ShouldAllowWithNoAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -372,7 +372,7 @@ public async Task Authorize_CustomRolePolicy() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -393,7 +393,7 @@ public async Task Authorize_HasAnyClaimOfTypePolicy() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -410,7 +410,7 @@ public async Task Authorize_PolicyCanAuthenticationSchemeWithNameClaim() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -427,7 +427,7 @@ public async Task RolePolicyCanRequireSingleRole() var allowed = await authorizationService.AuthorizeAsync(user, null, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -443,7 +443,7 @@ public async Task RolePolicyCanRequireOneOfManyRoles() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -464,7 +464,7 @@ public async Task RolePolicyCanBlockWrongRole() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -489,7 +489,7 @@ public async Task RolePolicyCanBlockNoRole() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -527,7 +527,7 @@ public async Task RequireUserNameFailsForWrongUserName() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -553,7 +553,7 @@ public async Task CanRequireUserName() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -575,7 +575,7 @@ public async Task CanRequireUserNameWithDiffClaimType() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -597,7 +597,7 @@ public async Task CanRequireRoleWithDiffClaimType() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -622,7 +622,7 @@ public async Task CanApproveAnyAuthenticatedUser() var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -642,7 +642,7 @@ public async Task CanBlockNonAuthenticatedUser() var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class CustomRequirement : IAuthorizationRequirement { } @@ -675,7 +675,7 @@ public async Task CustomReqWithNoHandlerFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -696,7 +696,7 @@ public async Task CustomReqWithHandlerSucceeds() 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 @@ public async Task PassThroughRequirementWillSucceedWithoutCustomHandler(bool sho var allowed = await authorizationService.AuthorizeAsync(user, null, "Passthrough"); // Assert - Assert.Equal(shouldSucceed, allowed); + Assert.Equal(shouldSucceed, allowed.Succeeded); } [Fact] @@ -764,7 +764,7 @@ public async Task CanCombinePolicies() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -791,7 +791,7 @@ public async Task CombinePoliciesWillFailIfBasePolicyFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -818,7 +818,7 @@ public async Task CombinedPoliciesWillFailIfExtraRequirementFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class ExpenseReport { } @@ -880,9 +880,9 @@ public async Task CanAuthorizeAllSuperuserOperations() // 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 @@ public async Task CanUseValueTypeResource() // 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 @@ public async Task DoesNotCallHandlerWithWrongResourceType() // 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 @@ public async Task CanAuthorizeOnlyAllowedOperations() // 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 @@ public async Task AuthorizeHandlerNotCalledWithNullResource() // 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 @@ public async Task CanAuthorizeWithAssertionRequirement() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -1015,7 +1015,7 @@ public async Task CanAuthorizeWithAsyncAssertionRequirement() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } public class StaticPolicyProvider : IAuthorizationPolicyProvider @@ -1049,7 +1049,7 @@ public async Task CanReplaceDefaultPolicyProvider() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class DynamicPolicyProvider : IAuthorizationPolicyProvider @@ -1081,23 +1081,15 @@ public async Task CanUseDynamicPolicyProvider() // 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 @@ public async Task CanUseCustomEvaluatorThatOverridesRequirement() 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 @@ public async Task CanUseCustomContextThatAlwaysFails() 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 48b134740..6eb74aeeb 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 000000000..216fc1440 --- /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 374/611] 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 93673ef00..0022d2743 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 375/611] Fix sln --- Security.sln | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/Security.sln b/Security.sln index 61ea7b0c3..7c34ff070 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 376/611] 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 bcc811de9..d5717b3f3 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 9de0185a4..0e1285a9c 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -15,6 +15,7 @@ public static void Main(string[] args) 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 02d0361b7..01a5ae9c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -22,7 +22,8 @@ public CookieAuthenticationOptions() 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 @@ public string CookieName /// /// 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 @@ public string CookieName /// /// 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 @@ public string CookieName /// 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 @@ public string CookieName /// /// 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 9c8f4ecc6..89d949a00 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -62,7 +62,7 @@ public OpenIdConnectHandler(IOptionsSnapshot options, ILog } /// - /// 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 @@ private void WriteNonceCookie(string nonce) 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 @@ private string ReadNonceCookie(string nonce) 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 63a18e83b..0eab83e41 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -31,7 +31,7 @@ internal class TwitterHandler : RemoteAuthenticationHandler 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 9394b7553..2ff06062d 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -12,7 +12,7 @@ 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 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand 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 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 7203e73e6..1e474bfe2 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -15,7 +15,7 @@ public class CookiePolicyOptions /// /// 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 737c12dc3..b6b2776a8 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -59,10 +59,10 @@ await RunTest("/secureAlways", 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 @@ await RunTest("/secureNone", 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 @@ await RunTest("/secureSame", 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 @@ await RunTest("/httpOnlyAlways", 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 @@ await RunTest("/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]); + 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 @@ public async Task CookiePolicyCanHijackAppend() 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 377/611] 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 f7e538a50..e804e1b39 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 378/611] 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 93f1ac47d..c4bc056c4 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 e804e1b39..02a36ec83 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 379/611] 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 5bf0e2c11..3a2476b2b 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 b0bcadb57..a40bdb87b 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 380/611] 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 c44069f43..1529dc803 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 d6e9d16e5..14c0aa2f1 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 381/611] 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 93f1ac47d..4e8a1f6de 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@  + diff --git a/version.props b/version.props index 0b2b8e001..90a2f5b5c 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 382/611] 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 af4a85b19..38211e0f1 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 b528dec9c..6f23abcc4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,7 +21,7 @@ public static IServiceCollection AddCookieAuthentication(this IServiceCollection 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 1bb065414..7d6fb8442 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 887789ebf..df1ab710b 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 c11b155d9..07d3e16d6 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 1041f1eec..bbc5e208a 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 d26bf6671..5c1e931f4 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 0bd3a9400..134e99920 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 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect 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 0aeed1183..8829bfac0 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 b0be3de97..60591e1e4 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 1a7fee370..ff743c972 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 257aed9cb..4ad0a8336 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -19,7 +19,7 @@ public static IServiceCollection AddOAuthAuthentication(this 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 99f65253a..e97346413 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 1a6450b7b..c39518515 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 b4ac4b9fb..6c965f047 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 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol 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 7421af9c0..b79f1d1ed 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 03d7ae809..62982fa19 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 11586f984..dac9ee351 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 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio 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 08e9c5b83..09db5699f 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 55bc09d8a..0e86b3a9f 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 ff367f555..7ebc979f1 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 @@ public static IServiceCollection AddRemoteScheme(this IServi 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 @@ public EnsureSignInScheme(IOptions authOptions) _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 383/611] 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 7d6fb8442..4f30b9ba9 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 @@ public static IServiceCollection AddFacebookAuthentication(this IServiceCollecti => 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 df1ab710b..000000000 --- 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 e39b31e90..a939958e2 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 07d3e16d6..be40822c5 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 @@ public static IServiceCollection AddGoogleAuthentication(this IServiceCollection => 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 bbc5e208a..000000000 --- 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 c4f1e7ad8..9f4cee9d5 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 5c1e931f4..000000000 --- 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 134e99920..582eb6314 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 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect 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 5b25e00e8..73d8fdd00 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 60591e1e4..000000000 --- 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 1a954c850..1accdf8f1 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 ff743c972..a4ad5692c 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 @@ public static IServiceCollection AddMicrosoftAccountAuthentication(this IService => 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 c39518515..000000000 --- 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 0ce2fe34e..8e4fb774d 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 6c965f047..d57640904 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 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol 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 62982fa19..000000000 --- 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 b78de6597..6bf4a66d3 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 dac9ee351..d8b78398f 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 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio 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 657c957bf..b463ef891 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,7 +20,6 @@ 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 @@ public async Task VerifySchemeDefaults() 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 b316e6275..501fdf603 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,7 +19,6 @@ 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 @@ public async Task VerifySchemeDefaults() 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 6746f5c3f..3149e9875 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,7 +19,6 @@ 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 @@ public async Task VerifySchemeDefaults() 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 0d49052f5..bf15c91b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,7 +20,6 @@ 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 @@ public async Task VerifySchemeDefaults() 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 9dc597b85..1708e604e 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.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 @@ public class OpenIdConnectTests 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 b8af66cdf..8fcc0780d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,7 +14,6 @@ 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 @@ public async Task VerifySchemeDefaults() 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 384/611] 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 d2687239b..ec7e8a7aa 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 385/611] 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 5123b7069..b8447e415 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 386/611] 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 bb2c10fee..9b04026cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,11 +6,8 @@ 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 @@ protected override Task InitializeHandlerAsync() { // 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 5cb933ce1..c7c375de2 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 @@ public class CookieAuthenticationEvents /// /// 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 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -66,7 +65,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -82,7 +81,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -98,7 +97,7 @@ public class CookieAuthenticationEvents { 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 41c4ff790..95aebf38b 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 c4e2e7b5a..a9b35c310 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 @@ public class JwtBearerEvents /// /// 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 6b1b1afd4..9755c5cb7 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 73d8fdd00..3c55004a4 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 4e94a15bc..b3572cab4 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 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// 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 @@ public class OAuthEvents : RemoteAuthenticationEvents 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 508c815fe..88d6794e9 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 f6386aeec..660eba0b3 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 @@ public class OpenIdConnectEvents : 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 => 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 8e4fb774d..d3789cd50 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 2c8b30e9f..c079ebb14 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 @@ public class TwitterEvents : RemoteAuthenticationEvents /// /// 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 @@ public class TwitterEvents : RemoteAuthenticationEvents 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 6bf4a66d3..8d834ee8d 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 b09470919..788df7e19 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -7,7 +7,6 @@ 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 @@ protected virtual async Task InitializeEventsAsync() /// A task protected virtual Task InitializeHandlerAsync() { - return TaskCache.CompletedTask; + return Task.CompletedTask; } protected string BuildRedirectUri(string targetPath) @@ -193,7 +192,7 @@ public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties pro protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } public async Task SignOutAsync(AuthenticationProperties properties) @@ -205,7 +204,7 @@ public async Task SignOutAsync(AuthenticationProperties properties) protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -216,7 +215,7 @@ protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) { Response.StatusCode = 403; - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -229,7 +228,7 @@ protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) 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 a130c1b14..83a6507d4 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 cbdb05b58..adbd5b3f1 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 b8447e415..83530a2be 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 4248e4813..93b1deea6 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -68,7 +67,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 5bae319b3..e88cce7aa 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 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte { 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 9fb295082..02ab946fa 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 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 44e2b9a22..811e17aac 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -62,7 +61,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte 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 0022d2743..15100fbbc 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 387/611] 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 02a36ec83..1fd0f3155 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 388/611] #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 660eba0b3..d8467be8d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -27,7 +27,9 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents 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 389/611] 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 95aebf38b..712aa8177 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 000000000..c223c035c --- /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 a939958e2..a9ec57199 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 000000000..f64e6b834 --- /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 9f4cee9d5..805de682f 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 000000000..db3d1fcf0 --- /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 3c55004a4..fe0bda164 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 000000000..d810a2bb9 --- /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 1accdf8f1..9437b5727 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 000000000..66f2a77b4 --- /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 88d6794e9..a15a75ee6 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 000000000..96fd03e98 --- /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 d3789cd50..ae8ffd8d5 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 000000000..4ba3fb756 --- /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 8d834ee8d..d9c5cd0b3 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 000000000..2023eb0b7 --- /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 adbd5b3f1..8a1f97042 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 000000000..0eb0bfaf5 --- /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 390/611] 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 ebb59c060..e6ad7804d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services) 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 89d949a00..f4dcea4c8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -182,7 +182,7 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper // 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 b2d69d524..a199016dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -167,15 +167,16 @@ public override void Validate() /// /// 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 1708e604e..99bc1ec8c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -119,7 +119,7 @@ public async Task SignOutWithCustomRedirectUri() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite 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 391/611] [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 f4dcea4c8..1dec54197 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -886,16 +886,21 @@ private void WriteNonceCookie(string nonce) 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 @@ private string ReadNonceCookie(string nonce) 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 a199016dd..a42f0eba3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -262,5 +262,11 @@ public override void Validate() /// 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 0eab83e41..baa4320d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -87,6 +87,8 @@ protected override async Task HandleRemoteAuthenticateAsync( Secure = Request.IsHttps }; + Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(StateCookie, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -159,6 +161,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 cf1bf4856..8b57f2502 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -58,6 +58,12 @@ public TwitterOptions() /// 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 2ff06062d..69c926cc0 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -205,9 +205,12 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 65cf6f2ec..066ca963a 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -87,5 +87,11 @@ public override void Validate() /// 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 2381fd6cd..dcc96c094 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 @@ public async Task ThrowsIfSignInSchemeMissing() 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 99bc1ec8c..6cfda3b85 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -60,6 +60,108 @@ public async Task SignOutSettingMessage() 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 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite [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 392/611] 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 9a480763d..0d0a88e24 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -47,7 +47,7 @@ public class JwtBearerOptions : AuthenticationSchemeOptions /// /// 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 393/611] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2a4610467..b10be1421 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 394/611] 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 c12815232..866b5dbc5 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -62,7 +62,7 @@ public static Task AuthorizeAsync(this IAuthorizationServic 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 395/611] Add NETStandardImplicitPackageVersion --- build/dependencies.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8f40044d1..f00799700 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 396/611] 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 | 22 +- .../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 | 50 +- .../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 | 25 +- .../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 | 15 +- .../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 | 29 +- .../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 | 24 +- .../PolicyEvaluator.cs | 4 +- .../CookieTests.cs | 45 +- .../FacebookTests.cs | 35 +- .../GoogleTests.cs | 26 +- .../JwtBearerTests.cs | 79 ++- .../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, 1712 insertions(+), 1459 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 79d1b3c3f..a91791070 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -18,9 +18,7 @@ public void ConfigureServices(IServiceCollection services) { 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 c35dfd999..f7b8f2bb8 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -19,9 +19,7 @@ public void ConfigureServices(IServiceCollection services) { 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 030e640c9..6f2c5e2ec 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -48,9 +48,7 @@ public void ConfigureServices(IServiceCollection services) { 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 @@ public void ConfigureServices(IServiceCollection services) { 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 e6ad7804d..aab6e60df 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -48,11 +48,9 @@ public void ConfigureServices(IServiceCollection services) 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 af1406289..bc5af750d 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -45,11 +45,9 @@ public void ConfigureServices(IServiceCollection services) 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 003972009..dcf76263d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -55,13 +55,11 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) }; 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 9b04026cd..4751c6f85 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,7 +14,10 @@ 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 @@ private async Task ReadCookieTicket() 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected virtual async Task FinishResponseAsync() } } - 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 @@ protected override async Task HandleSignInAsync(ClaimsPrincipal user, Authentica 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 @@ protected override async Task HandleSignInAsync(ClaimsPrincipal user, Authentica 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 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper // 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 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr if (redirectUri != null) { await Events.RedirectToReturnUrl( - new CookieRedirectContext(Context, Scheme, Options, redirectUri, properties)); + new RedirectContext(Context, Scheme, Options, properties, redirectUri)); } } } @@ -406,7 +422,7 @@ protected override async Task HandleForbiddenAsync(AuthenticationProperties prop 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } 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 6f23abcc4..67c4416eb 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; using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Options; using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.AspNetCore.Authentication; +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 4c949bb08..000000000 --- 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 c7c375de2..2b8b0416b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -37,7 +37,7 @@ public class CookieAuthenticationEvents /// /// 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 @@ public class CookieAuthenticationEvents /// /// 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 @@ public class CookieAuthenticationEvents /// /// 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 @@ public class CookieAuthenticationEvents /// /// 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 @@ private static bool IsAjaxRequest(HttpRequest request) /// 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 0e610c8b2..98c31dd19 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 b91cb7e18..41d7b4f6a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -7,9 +7,9 @@ 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 @@ public class CookieSigningInContext : BaseCookieContext /// 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 @@ public CookieSigningInContext( 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 0f4f4c7dc..34f6e49ab 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -6,9 +6,9 @@ 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 @@ public CookieSigningOutContext( 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 3232ba52f..d2161e42a 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 @@ public class CookieValidatePrincipalContext : BaseCookieContext /// /// 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 @@ public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme /// 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 000000000..d12735443 --- /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 38211e0f1..e6a62d1b6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -55,6 +55,5 @@ public void PostConfigure(string name, CookieAuthenticationOptions options) 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 c223c035c..91781d2dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -20,68 +20,28 @@ "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)", + "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.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)", + "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", - "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()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", "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)", + "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 4f30b9ba9..e4dcbfee8 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 c94048f9b..8a1f29bbe 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -42,13 +42,13 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 be40822c5..ee42c5564 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 3a93c5cbf..aa5e59649 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -39,14 +39,11 @@ protected override async Task CreateTicketAsync( 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 b47a9bab0..1c2efd6c7 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -6,12 +6,13 @@ 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 313e999d0..000000000 --- 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 e6f931f6d..6500e1e3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -6,15 +6,14 @@ 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 @@ public JwtBearerChallengeContext(HttpContext context, AuthenticationScheme schem /// 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 530a945ca..3c263f6b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -5,12 +5,13 @@ 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 3667865da..39b677b96 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -6,12 +6,13 @@ 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 582eb6314..4f051bd39 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 0087d38d0..999d323e1 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.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 @@ public JwtBearerHandler(IOptionsSnapshot options, ILoggerFacto 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 @@ protected override async Task HandleAuthenticateAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() // 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 @@ protected override async Task HandleAuthenticateAsync() // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } } @@ -138,29 +135,28 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected override async Task HandleAuthenticateAsync() }; 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 @@ protected override async Task HandleAuthenticateAsync() }; await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } throw; @@ -217,7 +213,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } await Events.Challenge(eventContext); - if (eventContext.IsProcessingComplete(out var ignored)) + if (eventContext.Handled) { return; } @@ -329,15 +325,5 @@ private static string CreateErrorDescription(Exception authFailure) 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 d810a2bb9..223ff401b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -16,43 +16,28 @@ "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)", + "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.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "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", - "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()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", "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)", + "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/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index a4ad5692c..9a53fd770 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 815b94bf4..45fae3d0e 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -32,12 +32,11 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 6e3105639..f660dd224 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 @@ public OAuthCreatingTicketContext( /// 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 @@ public OAuthCreatingTicketContext( 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 @@ public TimeSpan? ExpiresIn 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 b3572cab4..9e194491b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -19,7 +19,7 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// 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 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// 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 5d5e0e701..000000000 --- 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 4ad0a8336..5720d8e4f 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 bbe4f4038..b61d57537 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -42,7 +42,7 @@ public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, U /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( failureMessage.Append(";Uri=").Append(errorUri); } - return AuthenticateResult.Fail(failureMessage.ToString()); + return HandleRequestResult.Fail(failureMessage.ToString()); } var code = query["code"]; @@ -72,30 +72,30 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ private static async Task Display(HttpResponseMessage response) 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 96fd03e98..3124d7fe7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json @@ -24,23 +24,12 @@ "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()", + "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", - "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/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index 0c7d96863..203da93c5 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 0ccfc3ab7..bdf6e4a7f 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 63f815d9e..000000000 --- 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 f0298ed05..106ecb8c0 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 59b00827a..9961c237d 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 5c0172673..26720a58f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -6,16 +6,12 @@ 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 7c0d51fbb..2bebdb8dc 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 fea89298c..853857dc7 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 ee80cb71f..0b855eaf3 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 aa6d0cbaa..458cfd73e 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 @@ internal static class LoggingExtensions private static Action _remoteSignOut; private static Action _remoteSignOutSessionIdMissing; private static Action _remoteSignOutSessionIdInvalid; + private static Action _signOut; static LoggingExtensions() { @@ -63,10 +62,6 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ public static void RedirectToIdentityProviderForSignOutHandledResponse(this ILog _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 @@ public static void RemoteSignOutSessionIdInvalid(this ILogger logger) { _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 d57640904..7ba262bf3 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 1dec54197..341abbf5a 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 @@ protected virtual async Task HandleRemoteSignOutAsync() 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 @@ protected virtual async Task HandleRemoteSignOutAsync() /// 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 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper }; 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 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper 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 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper { throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); } + + Logger.SignedOut(Scheme.Name); } /// @@ -343,16 +344,11 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop }; 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop /// /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( PopulateSessionProperties(authorizationResponse, properties); - AuthenticationTicket ticket = null; + ClaimsPrincipal user = null; JwtSecurityToken jwt = null; string nonce = null; var validationParameters = Options.TokenValidationParameters.Clone(); @@ -543,7 +537,7 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( // 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( } 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// /// 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC } 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 @@ protected virtual async Task GetUserInformationAsync(OpenIdC 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 @@ private AuthenticationProperties GetPropertiesFromState(string state) 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 @@ private async Task RunAuthorizationCodeReceive 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) - { - Logger.AuthorizationCodeReceivedContextHandledResponse(); - } - else if (authorizationCodeReceivedContext.Skipped) + await Events.AuthorizationCodeReceived(context); + if (context.Result != null) { - 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) - { - Logger.TokenResponseReceivedHandledResponse(); - } - else if (eventContext.Skipped) + await Events.TokenResponseReceived(context); + if (context.Result != null) { - 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 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert 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 a42f0eba3..8bcedaec2 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 4ba3fb756..0f50b1210 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 b71b8655b..000000000 --- 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 eaf704bcb..67f28d529 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 @@ public class TwitterCreatingTicketContext : BaseTwitterContext /// 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 @@ public TwitterCreatingTicketContext( /// 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 c079ebb14..744c48c5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -19,7 +19,7 @@ public class TwitterEvents : RemoteAuthenticationEvents /// /// 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 @@ public class TwitterEvents : RemoteAuthenticationEvents /// 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 fe181fe7b..000000000 --- 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 d8b78398f..e49244920 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 baa4320d1..7fcc01eee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,7 @@ public TwitterHandler(IOptionsSnapshot options, ILoggerFactory l 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 @@ protected override async Task HandleRemoteAuthenticateAsync( if (requestToken == null) { - return AuthenticateResult.Fail("Invalid state cookie."); + return HandleRequestResult.Fail("Invalid state cookie."); } properties = requestToken.Properties; @@ -66,18 +66,18 @@ protected override async Task HandleRemoteAuthenticateAsync( 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 @@ protected override async Task HandleRemoteAuthenticateAsync( }); } - 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 @@ protected virtual async Task CreateTicketAsync( 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 2023eb0b7..6b8440911 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json @@ -20,43 +20,26 @@ "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", + "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.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", "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()", + "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.RequestToken", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", "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)", + "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 000000000..c29bdeae2 --- /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 788df7e19..aeb70cb0d 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -178,35 +178,6 @@ protected async Task HandleAuthenticateOnceSafeAsync() 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 7ebc979f1..28291f419 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 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi 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 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi 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 cfe5809c5..000000000 --- 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 3d65f0dd7..915fc2377 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 @@ protected BaseContext(HttpContext context) /// /// 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 fa582a304..000000000 --- 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 dad4c40fe..000000000 --- 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 000000000..52dd9ce12 --- /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 000000000..8bf40760a --- /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 000000000..f1730d0d7 --- /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 e4259d181..dac24cafa 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 000000000..b7a016879 --- /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 83a6507d4..ca0f4a5c0 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 5d2b30f13..becdfb543 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 000000000..12b21f4bf --- /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 c0797ea9c..51b77a37f 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 49fc8db05..ed15e6190 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,14 +9,8 @@ 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; @@ -26,18 +20,6 @@ internal static class LoggingExtensions 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 @@ static LoggingExtensions() 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 @@ static LoggingExtensions() 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 @@ public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, str _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 @@ public static void AuthenticationSchemeForbidden(this ILogger logger, string aut _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 69c926cc0..62213a171 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 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand } 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 @@ public virtual async Task HandleRequestAsync() { return true; } - else if (authResult.Nothing) + else if (authResult.Skipped || authResult.None) { return false; } @@ -89,25 +82,28 @@ public virtual async Task HandleRequestAsync() 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) - { - return true; - } - else if (errorContext.Skipped) + if (errorContext.Result != null) { - 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 @@ public virtual async Task HandleRequestAsync() 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 @@ public virtual async Task HandleRequestAsync() /// /// 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 @@ protected override async Task HandleAuthenticateAsync() 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 066ca963a..a5f0bb44b 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -23,11 +23,6 @@ public override void Validate() { 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 000000000..8bcd2be01 --- /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 0eb0bfaf5..81dc1133e 100644 --- a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -84,43 +84,33 @@ "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)", + "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.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions get_Options()", + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.BaseContext", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public System.Void set_Options(Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions value)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.FailureContext : Microsoft.AspNetCore.Authentication.BaseControlContext", "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)", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public System.Void SkipToNextMiddleware()", + "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 60f291f67..f93c2d92a 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -52,13 +52,13 @@ public virtual async Task AuthenticateAsync(AuthorizationPol 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 677120e4b..7dade96ee 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 @@ public class CookieTests [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 @@ private Task SignOutAsWrong(HttpContext context) [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 @@ public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) } 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 @@ public async Task ChallengeDoesNotSet401OnUnauthorized() 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 @@ public async Task CanConfigureDefaultCookieInstance() }) .ConfigureServices(services => { - services.AddCookieAuthentication(); + services.AddAuthentication().AddCookie(); services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, o => o.CookieName = "One"); }); @@ -844,7 +846,7 @@ public async Task CanConfigureNamedCookieInstance() }) .ConfigureServices(services => { - services.AddCookieAuthentication("Cookie1"); + services.AddAuthentication().AddCookie("Cookie1"); services.Configure("Cookie1", o => o.CookieName = "One"); }); @@ -866,7 +868,7 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() 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 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() 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 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() 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 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() 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 @@ public async Task MapWillNotAffectAccessDenied() 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 @@ public async Task NestedMapWillNotAffectLogin() 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 @@ public async Task NestedMapWillNotAffectAccessDenied() 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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ public async Task CanSpecifyAndShareDataProtector() 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 @@ private TestServer CreateServer(Action configureOpt => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddCookieAuthentication(configureOptions); + s.AddAuthentication().AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); @@ -1281,6 +1283,15 @@ private static TestServer CreateServerWithServices(Action co { 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 b463ef891..e6b5574df 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -85,9 +85,9 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() { 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 @@ public async Task NestedMapWillNotAffectRedirect() }), 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 @@ public async Task MapWillNotAffectRedirect() }, 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 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 501fdf603..2eae26670 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -516,7 +516,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ public async Task NullRedirectUriWillRedirectToSlash() { OnTicketReceived = context => { - context.Ticket.Properties.RedirectUri = null; + context.Properties.RedirectUri = null; return Task.FromResult(0); } }; @@ -985,7 +985,7 @@ private static TestServer CreateServer(Action configureOptions, F 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 @@ private static TestServer CreateServer(Action configureOptions, F 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 @@ private static TestServer CreateServer(Action configureOptions, F } 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 @@ private static TestServer CreateServer(Action configureOptions, F 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 3149e9875..a9b158d2b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -127,11 +127,8 @@ public async Task CustomHeaderReceived() 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 @@ public async Task CustomTokenValidated() { // 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 @@ public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() { OnMessageReceived = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnTokenValidated = context => @@ -420,7 +417,7 @@ public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() + public async Task EventOnMessageReceivedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -428,7 +425,7 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() { 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 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() }; }); - 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 @@ public async Task EventOnTokenValidatedSkip_NoMoreEventsExecuted() { OnTokenValidated = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnAuthenticationFailed = context => @@ -483,7 +483,7 @@ public async Task EventOnTokenValidatedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() + public async Task EventOnTokenValidatedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -491,7 +491,7 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() { 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 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() 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 @@ public async Task EventOnAuthenticationFailedSkip_NoMoreEventsExecuted() }, OnAuthenticationFailed = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnChallenge = context => @@ -544,7 +547,7 @@ public async Task EventOnAuthenticationFailedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() + public async Task EventOnAuthenticationFailedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -556,7 +559,7 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() }, OnAuthenticationFailed = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -569,35 +572,16 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() 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); - } - - [Fact] - public async Task EventOnChallengeSkip_ResponseNotModified() - { - var server = CreateServer(o => + var exception = await Assert.ThrowsAsync(delegate { - o.Events = new JwtBearerEvents() - { - OnChallenge = context => - { - context.Skip(); - return Task.FromResult(0); - }, - }; + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); }); - 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); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } - [Fact] - public async Task EventOnChallengeHandled_ResponseNotModified() + public async Task EventOnChallengeSkip_ResponseNotModified() { var server = CreateServer(o => { @@ -606,14 +590,13 @@ public async Task EventOnChallengeHandled_ResponseNotModified() 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.Equal(HttpStatusCode.OK, response.Response.StatusCode); Assert.Empty(response.Response.Headers.WwwAuthenticate); Assert.Equal(string.Empty, response.ResponseText); } @@ -752,11 +735,11 @@ private static TestServer CreateServer(Action options = null, } 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 bf15c91b0..f51694043 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -159,7 +159,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() 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 @@ private static TestServer CreateServer(Action configure } 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 @@ private static TestServer CreateServer(Action configure 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 dcc96c094..bdd79533b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -143,29 +143,6 @@ public async Task ThrowsIfAuthorizationEndpointMissing() 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 3c0146b08..d21a1f424 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -335,7 +335,7 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() // 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 @@ public async Task OnRedirectToIdentityProviderEventSkipResponse() { 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 3ceb4a533..74f00c8f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -22,8 +22,9 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() 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 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() 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 @@ private TestServer BuildTestServer(Action options) 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 607e9bb62..4ea69369e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -34,7 +34,7 @@ public class OpenIdConnectEventTests 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 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() OnMessageReceived = context => { messageReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenValidated = TokenNotImpl, @@ -75,6 +75,51 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -151,6 +196,57 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { tokenValidated = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -209,8 +305,7 @@ public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() OnTokenValidated = context => { tokenValidated = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -262,7 +357,7 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() OnAuthorizationCodeReceived = context => { codeReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -289,6 +384,63 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsR { codeReceived = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -358,8 +510,7 @@ public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketRece OnAuthorizationCodeReceived = context => { codeReceived = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -417,7 +568,7 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -444,6 +595,69 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived OnTokenResponseReceived = context => { tokenResponseReceived = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -584,7 +797,7 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -611,6 +824,69 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsR 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 @@ public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketRece OnTokenValidated = context => { tokenValidated = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -757,7 +1032,7 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() OnUserInformationReceived = context => { userInfoReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -784,6 +1059,75 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun 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 @@ public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceiv { userInfoReceived = true; // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -949,7 +1293,7 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -976,6 +1320,82 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { 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 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Ticket); + Assert.Null(context.Principal); var claims = new[] { @@ -1092,11 +1512,8 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( 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 @@ public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTicketReceived = TicketNotImpl, @@ -1314,7 +1731,7 @@ public async Task OnTicketReceived_Skip_NoMoreEventsRun() OnTicketReceived = context => { ticektReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, @@ -1408,8 +1825,9 @@ private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appC 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 6cfda3b85..7f9d42b1c 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 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 aa7f6179b..1ffb9ff68 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -112,10 +112,10 @@ await context.SignOutAsync( 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 afdef0a40..05e5708de 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -134,7 +134,7 @@ public void UpdateTokenValueReturnsFalseForUnknownToken() // return Task.FromResult(0); // } - // public Task ChallengeAsync(ChallengeContext context) + // public Task ChallengeAsync(AuthenticationProperties properties) // { // throw new NotImplementedException(); // } @@ -144,12 +144,12 @@ public void UpdateTokenValueReturnsFalseForUnknownToken() // 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 8fcc0780d..76f6b1aad 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.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -177,15 +175,15 @@ private static TestServer CreateServer(Action options, Func(() => 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 @@ private static TestServer CreateServer(Action options, Func { - 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 b6b2776a8..5c2458c52 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -312,7 +312,7 @@ public async Task CookiePolicyAppliesToCookieAuth() var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(o => + services.AddAuthentication().AddCookie(o => { o.CookieName = "TestCookie"; o.CookieHttpOnly = false; @@ -352,7 +352,7 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() 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 ae5e6f018..e2e4fd7d0 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -68,7 +68,7 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() 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 @@ public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() 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 @@ public async Task InteropWithNewCookieContainsIdentity() 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 @@ public async Task InteropWithLargeNewCookieContainsIdentity() 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 397/611] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b..7b2956ece 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 398/611] 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 aeb70cb0d..a258d0aca 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,6 +142,10 @@ public async Task AuthenticateAsync() 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 ed15e6190..46223d647 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,6 +9,7 @@ internal static class LoggingExtensions { 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 @@ static LoggingExtensions() 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 @@ public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, str _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 399/611] Replace configure method on Twitter, RemoteAuthentication, and OpenIdConnect options with CookieBuilder --- .../OpenIdConnectHandler.cs | 42 ++++---------- .../OpenIdConnectOptions.cs | 50 +++++++++++++++-- .../TwitterHandler.cs | 27 ++------- .../TwitterOptions.cs | 53 ++++++++++++++---- .../Internal/RequestPathBaseCookieBuilder.cs | 38 +++++++++++++ .../RemoteAuthenticationHandler.cs | 32 ++--------- .../RemoteAuthenticationOptions.cs | 55 +++++++++++++++++-- .../OAuthTests.cs | 2 +- .../OpenIdConnect/OpenIdConnectTests.cs | 4 +- 9 files changed, 202 insertions(+), 101 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 341abbf5a..9e6d34bc9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -275,8 +275,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) /// 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 @@ protected override async Task HandleRemoteAuthenticateAsync 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 @@ private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessag 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 @@ private void WriteNonceCookie(string nonce) 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 @@ private string ReadNonceCookie(string nonce) 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 @@ private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties p 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 8bcedaec2..23169b5bc 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 @@ public OpenIdConnectOptions() 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 @@ public override void Validate() /// 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 @@ public override void Validate() 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 7fcc01eee..ddcd095d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -10,7 +10,6 @@ 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 @@ protected override async Task HandleRemoteAuthenticateAsync { 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 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail("Missing or blank oauth_verifier"); } - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.Lax, - Secure = Request.IsHttps - }; - - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - Response.Cookies.Delete(StateCookie, cookieOptions); + Response.Cookies.Delete(Options.StateCookie.Name, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -144,17 +135,9 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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), - }; - - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - 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 8b57f2502..0190f21a6 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 @@ public TwitterOptions() Events = new TwitterEvents(); ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + + _stateCookieBuilder = new TwitterCookieBuilder(this) + { + Name = DefaultStateCookieName, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + HttpOnly = true, + SameSite = SameSiteMode.Lax, + }; } /// @@ -59,18 +68,42 @@ public TwitterOptions() 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. + /// Gets or sets the used to handle authentication events. /// - public Action ConfigureStateCookie { get; set; } + public new TwitterEvents Events + { + get => (TwitterEvents)base.Events; + set => base.Events = value; + } /// - /// Gets or sets the used to handle authentication events. + /// Determines the settings used to create the state cookie before the + /// cookie gets added to the response. /// - public new TwitterEvents Events + public CookieBuilder StateCookie + { + get => _stateCookieBuilder; + set => _stateCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class TwitterCookieBuilder : CookieBuilder { - get { return (TwitterEvents)base.Events; } - set { base.Events = value; } + 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 000000000..f42617cb2 --- /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 62213a171..7bd3b0773 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,7 +5,6 @@ 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 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties 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 a5f0bb44b..3b34cf43e 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 @@ public override void Validate() 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 @@ public override void Validate() 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 bdd79533b..62d11e52a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -190,7 +190,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv 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 7f9d42b1c..b7ac1f82d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -92,7 +92,7 @@ public async Task RedirectToIdentityProvider_NonceCookieOptions_CanBeOverriden() { AuthorizationEndpoint = "https://example.com/provider/login" }; - opt.ConfigureNonceCookie = (ctx, options) => options.Path = "/"; + opt.NonceCookie.Path = "/"; }); var server = setting.CreateTestServer(); @@ -143,7 +143,7 @@ public async Task RedirectToIdentityProvider_CorrelationIdCookieOptions_CanBeOve { 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 400/611] 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 7c34ff070..2e5ee56d0 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 4751c6f85..e093e87b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,9 +14,9 @@ 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 @@ public CookieAuthenticationHandler(IOptionsSnapshot { } /// - /// 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 @@ private void RequestRefresh(AuthenticationTicket ticket) 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 @@ protected override async Task HandleAuthenticateAsync() 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 @@ protected virtual async Task FinishResponseAsync() Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, cookieOptions); @@ -283,14 +270,14 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper 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 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, signInContext.CookieOptions); @@ -359,7 +346,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) 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 01a5ae9c9..4f8b201ad 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 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions 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 @@ public string CookieName /// 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 @@ public string CookieName /// 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 712aa8177..fb20a55b9 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 e6a62d1b6..48895072e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -28,9 +28,9 @@ public void PostConfigure(string name, CookieAuthenticationOptions options) { 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 e2719f39d..000000000 --- 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 7dade96ee..1471caf44 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -18,7 +18,6 @@ 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 @@ public async Task SignInCausesDefaultCookieToBeCreated() 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 @@ public async Task SignInWrongAuthTypeThrows() 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 @@ public async Task SignOutWrongAuthTypeThrows() 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 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( 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 @@ public async Task CookieOptionsAlterSetCookieHeader() { 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 @@ public async Task CookieOptionsAlterSetCookieHeader() 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 @@ public async Task CookieStopsWorkingAfterExpiration() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -307,7 +306,7 @@ public async Task CookieExpirationCanBeOverridenInSignin() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -340,7 +339,7 @@ public async Task ExpiredCookieWithValidatorStillExpired() { 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 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() { 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 @@ public async Task CookieNotRenewedAfterSignOut() { 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 @@ public async Task CookieCanBeRenewedByValidator() { 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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { 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 @@ public async Task CookieValidatorOnlyCalledOnce() { 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task CookieExpirationCanBeOverridenInEvent() { 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 @@ public async Task CookieIsRenewedWithSlidingExpiration() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = true; }, SignInAsAlice); @@ -825,7 +824,7 @@ public async Task CanConfigureDefaultCookieInstance() { 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 @@ public async Task CanConfigureNamedCookieInstance() { 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 @@ public async Task RedirectUriIsHoneredAfterSignin(string redirectUrl) var server = CreateServer(o => { o.LoginPath = "/testpath"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => await context.SignInAsync( @@ -1006,7 +1005,7 @@ public async Task RedirectUriInQueryIsHoneredAfterSignin() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1028,7 +1027,7 @@ public async Task AbsoluteRedirectUriInQueryStringIsRejected() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1049,7 +1048,7 @@ public async Task EnsurePrecedenceOfRedirectUriAfterSignin() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1102,7 +1101,7 @@ public async Task CanSpecifyAndShareDataProtector() .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 @@ public async Task CanSpecifyAndShareDataProtector() }) .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 5c2458c52..49089234e 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -314,9 +314,9 @@ public async Task CookiePolicyAppliesToCookieAuth() { 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 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() { 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 401/611] 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 67c4416eb..61f72e361 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -25,20 +25,5 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder 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 e4dcbfee8..1cb1ef03e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -17,16 +17,5 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build 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 ee42c5564..7bb9b7beb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -17,17 +17,5 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder 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 4f051bd39..698c0118e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -22,19 +22,5 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil 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 9a53fd770..8da6daaac 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -17,17 +17,5 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild 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 5720d8e4f..8c9d34c5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -21,19 +21,5 @@ public static AuthenticationBuilder AddOAuth(this Authentica 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 7ba262bf3..43059b3ff 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -22,18 +22,5 @@ public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder 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 e49244920..bd0a3b1e2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -22,18 +22,5 @@ public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builde 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 eba561d1d..0c62cc3c3 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -37,8 +37,6 @@ public async Task Invoke(HttpContext context) 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 e6b5574df..43c52b0fd 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.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 @@ public class FacebookTests [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 @@ public async Task ThrowsIfAppIdMissing() { 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 @@ public async Task ThrowsIfAppSecretMissing() { 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 2eae26670..3bfea45df 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -29,7 +29,8 @@ public class GoogleTests [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 a9b158d2b..c7153ded3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -29,7 +29,8 @@ public class JwtBearerTests [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 @@ private static TestServer CreateServer(Action options = null, } }); }) - .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 f51694043..941dd1348 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -30,7 +30,8 @@ public class MicrosoftAccountTests [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 62d11e52a..ea0c941c9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -19,7 +19,8 @@ public class OAuthTests [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 @@ public async Task ThrowsIfClientIdMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; o.CallbackPath = "/"; @@ -56,7 +57,7 @@ public async Task ThrowsIfClientSecretMissing() { 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 @@ public async Task ThrowsIfCallbackPathMissing() { 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 @@ public async Task ThrowsIfTokenEndpointMissing() { 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 @@ public async Task ThrowsIfAuthorizationEndpointMissing() { 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 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB { var server = CreateServer( app => { }, - s => s.AddOAuthAuthentication( + s => s.AddAuthentication().AddOAuth( "Weblie", opt => { @@ -180,7 +181,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv { 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 76f6b1aad..1c387d889 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -10,7 +10,6 @@ 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 @@ public class TwitterTests [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 402/611] #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 999d323e1..1cb1ea449 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -90,17 +90,11 @@ protected override async Task HandleAuthenticateAsync() 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 9e6d34bc9..068593837 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -1137,16 +1137,11 @@ private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties p 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 403/611] 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 e093e87b7..f41199752 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -270,14 +270,14 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper 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 4f8b201ad..ec67ecc18 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,7 +21,6 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions SameSite = SameSiteMode.Lax, HttpOnly = true, SecurePolicy = CookieSecurePolicy.SameAsRequest, - Expiration = TimeSpan.FromDays(14), }; /// @@ -29,6 +28,7 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions /// public CookieAuthenticationOptions() { + ExpireTimeSpan = TimeSpan.FromDays(14); ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; SlidingExpiration = true; Events = new CookieAuthenticationEvents(); @@ -42,7 +42,6 @@ public CookieAuthenticationOptions() /// defaults to . /// defaults to true. /// defaults to . - /// defaults to 14 days. /// /// /// @@ -60,9 +59,7 @@ public CookieAuthenticationOptions() /// 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 @@ public CookieBuilder Cookie /// 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 @@ public CookieBuilder Cookie /// [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 fb20a55b9..712aa8177 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 1471caf44..c2d843bf1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -143,6 +143,23 @@ public async Task SignInCausesDefaultCookieToBeCreated() 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 @@ public async Task CookieStopsWorkingAfterExpiration() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -306,7 +323,7 @@ public async Task CookieExpirationCanBeOverridenInSignin() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -339,7 +356,7 @@ public async Task ExpiredCookieWithValidatorStillExpired() { 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 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() { 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 @@ public async Task CookieNotRenewedAfterSignOut() { 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 @@ public async Task CookieCanBeRenewedByValidator() { 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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { 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 @@ public async Task CookieValidatorOnlyCalledOnce() { 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 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) 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 @@ public async Task CookieExpirationCanBeOverridenInEvent() { 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 @@ public async Task CookieIsRenewedWithSlidingExpiration() { 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 404/611] 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 f00799700..44605092c 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 405/611] 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 f41199752..996c334a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -32,7 +32,7 @@ public class CookieAuthenticationHandler : 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 8a1f29bbe..9004fc09c 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 aa5e59649..7a2e1a2d1 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 1cb1ea449..9cf73182b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -22,7 +22,7 @@ internal class JwtBearerHandler : AuthenticationHandler { 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 45fae3d0e..8204bf07b 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 b61d57537..007d7dbef 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 068593837..65e1e1951 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -55,7 +55,7 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler 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 ddcd095d5..1e1dd08d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -38,7 +38,7 @@ internal class TwitterHandler : RemoteAuthenticationHandler 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 a258d0aca..d1d09f074 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -40,7 +40,7 @@ protected HttpResponse Response 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 @@ protected string CurrentUri } } - 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 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte 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 7bd3b0773..bcd598364 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -31,7 +31,7 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand 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 d239d85f8..fe7443679 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 @@ public async Task CanAddAndRemoveSchemes() 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 @@ public async Task VerifyDefaultBehavior() await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); } - private class TestHandler : AuthenticationHandler + public class TestOptions : AuthenticationSchemeOptions + { + public Singleton Instance { get; set; } + } + + public class Singleton { - public TestHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + 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 @@ protected override Task HandleAuthenticateAsync() 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 @@ private static TestServer CreateServer(Action configureAu }) .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 406/611] 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 dc4ad9a78..1555ad638 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 407/611] 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 90a2f5b5c..b94223e00 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 408/611] 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 1555ad638..f7497c8f4 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 d251b844e..64438de77 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 a2d0490f1..cb07f4385 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 c2f73fd96..fe2a5fa9d 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 785724908..ece748d0d 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 03384f567..9f62a06b5 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 999dc91a6..d35796f75 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 409/611] 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 c2d843bf1..83083cbf0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ private TestServer CreateServer(Action configureOpt => 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 fe7443679..d658609b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -86,24 +86,6 @@ public async Task CanAddAndRemoveSchemes() 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 43c52b0fd..35752ec6b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -81,8 +81,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() { services.AddAuthentication(options => { - options.DefaultSignInScheme = "External"; - options.DefaultAuthenticateScheme = "External"; + options.DefaultScheme = "External"; }) .AddCookie("External", o => { }) .AddFacebook(o => @@ -221,7 +220,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() { 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 3bfea45df..f1038bb51 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -1050,7 +1050,7 @@ private static TestServer CreateServer(Action configureOptions, F 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 c7153ded3..e001bd995 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ private static TestServer CreateServer(Action options = null, } }); }) - .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 941dd1348..b63ad1f7d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -226,7 +226,7 @@ private static TestServer CreateServer(Action configure { 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 1ffb9ff68..4d6a26821 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -111,7 +111,7 @@ await context.SignOutAsync( { 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 410/611] 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 28291f419..e1beea7b6 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -27,6 +27,9 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se 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 83083cbf0..c711fde49 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ private TestServer CreateServer(Action configureOpt => 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 35752ec6b..75de0652e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -79,10 +79,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }, services => { - services.AddAuthentication(options => - { - options.DefaultScheme = "External"; - }) + services.AddAuthentication("External") .AddCookie("External", o => { }) .AddFacebook(o => { @@ -218,10 +215,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 e001bd995..97adb2105 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ private static TestServer CreateServer(Action options = null, } }); }) - .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 b63ad1f7d..2e249a833 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -224,11 +224,7 @@ private static TestServer CreateServer(Action configure }) .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 4d6a26821..c37da8c04 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -109,11 +109,7 @@ await context.SignOutAsync( }) .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 411/611] 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 4e8a1f6de..37f0d27ea 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 412/611] 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 5bf0e2c11..178533438 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 b0bcadb57..5e27ed8ef 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 413/611] 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 1041615c6..31efd8196 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 414/611] 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 44605092c..3ceeb8708 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 aab6e60df..6a6abd7c3 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -45,8 +45,7 @@ public void ConfigureServices(IServiceCollection services) { 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 bc5af750d..3325ea3c3 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -147,7 +147,7 @@ await WriteHtmlAsync(context.Response, async res => // 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 415/611] #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 6a6abd7c3..c3fa3c719 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -49,7 +49,7 @@ public void ConfigureServices(IServiceCollection services) 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 dcf76263d..8a59928c4 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -70,7 +70,7 @@ public void ConfigureServices(IServiceCollection services) }) // 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 @@ public void ConfigureServices(IServiceCollection services) */ // 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 @@ public void ConfigureServices(IServiceCollection services) }) // 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 61f72e361..4c41f54a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,9 +21,12 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder => 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 012f95dcc..6143a4f23 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -7,6 +7,8 @@ public static class FacebookDefaults { 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 1cb1ef03e..2273724a4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build => 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 77d68aed9..e4bd66615 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -10,6 +10,8 @@ public static class GoogleDefaults { 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 7bb9b7beb..95547014c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder => 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 698c0118e..334407c0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil => 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 0d272f979..1b0859c5b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -7,6 +7,8 @@ public static class MicrosoftAccountDefaults { 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 8da6daaac..7f24e5af7 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild => 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 000000000..376f8ab01 --- /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 8c9d34c5f..22c541a0a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -14,12 +14,20 @@ 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, 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 c5baca4db..f98ba87e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -19,9 +19,9 @@ public static class OpenIdConnectDefaults 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 43059b3ff..f427bebaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder => 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 23169b5bc..a8545e35a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -27,7 +27,6 @@ public class OpenIdConnectOptions : RemoteAuthenticationOptions /// 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 0f50b1210..931a7b079 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 0610ccfc9..a39a3f036 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 bd0a3b1e2..724380569 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builde => 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 ea0c941c9..aeb313daa 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -26,7 +26,7 @@ public async Task VerifySchemeDefaults() 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 416/611] 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 ece748d0d..cd8b6976f 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 9f62a06b5..b3d875d47 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 417/611] 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 b10be1421..6c59666f3 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 1041615c6..04dfabcb0 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 418/611] 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 3ceeb8708..85abdc894 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 419/611] 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 85abdc894..3ceeb8708 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 420/611] 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 1717a0ae0..dd5e6fc03 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs @@ -28,9 +28,13 @@ public interface IPolicyEvaluator /// 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 f93c2d92a..3100ff4d3 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -67,17 +67,21 @@ public virtual async Task AuthenticateAsync(AuthorizationPol /// 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 216fc1440..2384e6db5 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 @@ public class PolicyEvaluatorTests 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 @@ public async Task AuthenticateFailsIfNoPrincipalReturned() 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 @@ public async Task AuthenticateMergeSchemes() 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 @@ public async Task AuthorizeSucceedsEvenIfAuthenticationFails() 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 @@ public async Task AuthorizeChallengesIfAuthenticationFails() 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 @@ public async Task AuthorizeForbidsIfAuthenticationSuceeds() 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 421/611] 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 3c263f6b2..1850ad049 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -14,7 +14,7 @@ public MessageReceivedContext( : 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 106ecb8c0..7d06e4479 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -18,7 +18,7 @@ public MessageReceivedContext( 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 422/611] 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 b94223e00..cb77b4393 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 423/611] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3ceeb8708..4a2338b8b 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 424/611] 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 4a2338b8b..a97cae9f6 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 425/611] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + build.cmd | 2 +- build.ps1 | 206 +++++++++++++++++++++++++++++++++---------- build.sh | 212 ++++++++++++++++++++++++++++++++++++++------- build/common.props | 2 +- version.props | 7 -- version.xml | 8 ++ 7 files changed, 350 insertions(+), 88 deletions(-) delete mode 100644 version.props create mode 100644 version.xml diff --git a/.gitignore b/.gitignore index d5717b3f3..bac5b7505 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 7d4894cb4..b6c8d2486 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 5bf0e2c11..d5eb4d5cf 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$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 +#!/usr/bin/env powershell +#requires -version 4 + +<# +.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 +} + +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -cd $PSScriptRoot +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return + } -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder + $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" + } + } -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP + Write-Error "Download failed: '$RemotePath'." } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" +# +# Main +# -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" +# Load configuration or set defaults - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null +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' } +} - $localZipFile="$tempFolder\korebuild.zip" +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'} +} - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) +# Execute - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder - } +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore } - -&"$buildFile" @args diff --git a/build.sh b/build.sh index b0bcadb57..ab590e62f 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 + +# +# variables +# -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +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='' -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +# +# 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." - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} - localZipFile="$tempFolder/korebuild.zip" +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" - 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 + { + 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 - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - unzip -q -d $tempFolder $localZipFile + 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 - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi - chmod +x $buildFile + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + 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 f7497c8f4..ea940214e 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 cb77b4393..000000000 --- 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 000000000..3c05022b7 --- /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 426/611] 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 ab590e62f..5568c6182 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 427/611] Update __get_remote_file logic --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5568c6182..8eace4c20 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 428/611] 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 8eace4c20..11cdbe550 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 429/611] 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 bb5cdfff0..bdfd43c79 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 1a9607eea..a94dc7bc4 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 ec7e8a7aa..4302d20db 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 9755c5cb7..0cfc97573 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 88306efbe..7fd71d7a9 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 ceec294ec..d55f311f7 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 db5cfbbcc..0746ae3fd 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 2896365d6..36e1111da 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 430/611] 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 3325ea3c3..c05bc8b52 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.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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) }); } - 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => 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 @@ await WriteHtmlAsync(context.Response, async res => return; } - await WriteHtmlAsync(context.Response, async response => + if (context.Request.Path.Equals("/refresh")) + { + var refreshToken = props.GetTokenValue("refresh_token"); + + 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 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 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 response.WriteAsync("

Claims:

"); - await WriteTableHeader(response, 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 8a59928c4..d69b25ee3 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.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.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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) { 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void Configure(IApplicationBuilder app) 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 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; } - await context.Response.WriteAsync(""); + + 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 @@ public void Configure(IApplicationBuilder app) { 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 @@ public void Configure(IApplicationBuilder app) { 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 @@ public void Configure(IApplicationBuilder app) 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 @@ public void Configure(IApplicationBuilder app) } // 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 431/611] #772 Fill in OIDC test gaps --- samples/SocialSample/Startup.cs | 2 +- .../OpenIdConnectChallengeTests.cs | 38 +++++++++++++------ .../OpenIdConnect/OpenIdConnectEventTests.cs | 14 +++---- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index d69b25ee3..36a53b38a 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -162,7 +162,7 @@ public void ConfigureServices(IServiceCollection services) }) // 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 d21a1f424..fb08ae278 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.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 @@ public class OpenIdConnectChallengeTests 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 @@ Example of a form post */ [Fact] - public async Task ChallengeIssueedCorrectlyForFormPost() + public async Task ChallengeFormPostIssuedCorrectly() { var settings = new TestSettings( opt => @@ -361,24 +362,37 @@ public async Task OnRedirectToIdentityProviderEventHandleResponse() 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 secondCookie = transaction.SetCookie.Skip(1).First(); - Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); - Assert.Contains("expires", secondCookie); + 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 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 4ea69369e..ed20d2f5a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -76,7 +76,7 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnMessageReceived_Reject_NoMoreEventsRun() + public async Task OnMessageReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var remoteFailure = false; @@ -197,7 +197,7 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenValidated_Reject_NoMoreEventsRun() + public async Task OnTokenValidated_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -385,7 +385,7 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnAuthorizationCodeReceived_Reject_NoMoreEventsRun() + public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -596,7 +596,7 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenResponseReceived_Reject_NoMoreEventsRun() + public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -825,7 +825,7 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenValidatedBackchannel_Reject_NoMoreEventsRun() + public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() { var messageReceived = false; var codeReceived = false; @@ -1060,7 +1060,7 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnUserInformationReceived_Reject_NoMoreEventsRun() + public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1321,7 +1321,7 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() } [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 432/611] 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 49089234e..7c34f950a 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -273,7 +273,7 @@ public async Task CookiePolicyCanHijackDelete() 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 433/611] #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 b7ac1f82d..32be26d33 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -182,27 +182,39 @@ public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled } [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.Redirect, transaction.Response.StatusCode); - Assert.True(transaction.Response.Headers.Location.AbsoluteUri.StartsWith(configuration.EndSessionEndpoint)); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') - .Select(each => each.Split('=')) - .ToDictionary(pair => pair[0], pair => pair[1]); + settings.ValidateSignoutFormPost(transaction, + OpenIdConnectParameterNames.PostLogoutRedirectUri); + } - 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); + [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); + + 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 9d9e5537f..bf9df4038 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -80,6 +80,44 @@ public IDictionary ValidateChallengeFormPost(string responseBody 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 @@ private void ValidateParameters( 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 @@ private void ValidateExpectedAuthority(string absoluteUri, ICollection e } } - 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 actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualParams, errors, htmlEncoded); - private void ValidateResponseType(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualQuery, errors, htmlEncoded); + private void ValidateResponseMode(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualParams, errors, htmlEncoded); - private void ValidateResponseMode(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualQuery, errors, htmlEncoded); + private void ValidateScope(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualParams, 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 actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualParams, errors, htmlEncoded); - private void ValidateRedirectUri(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); + private void ValidateResource(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualParams, errors, htmlEncoded); - private void ValidateResource(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualQuery, errors, htmlEncoded); + private void ValidateState(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); - private void ValidateState(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.State, ExpectedState, actualQuery, errors, htmlEncoded); + private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualParams, errors, htmlEncoded); - private void ValidateSkuTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", 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 ValidateVersionTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); + private void ValidatePostLogoutRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.PostLogoutRedirectUri, "https://example.com/signout-callback-oidc", actualParams, errors, htmlEncoded); - private void ValidateQueryParameter( + 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 @@ private void ValidateQueryParameter( 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 434/611] =?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 0190f21a6..86919d092 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 @@ public CookieBuilder StateCookie 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 1c387d889..746dfee6a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -63,7 +63,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() } }; }, - context => + context => { // REVIEW: Gross context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); @@ -75,6 +75,36 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() 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 435/611] 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 ec67ecc18..420435daf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -196,7 +196,7 @@ public CookieBuilder Cookie /// 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 436/611] 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 420435daf..0f2dbd312 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -161,7 +161,7 @@ public CookieBuilder Cookie /// 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 437/611] 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 a97cae9f6..0f73dd1b4 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 c711fde49..d346c68d7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -54,8 +54,8 @@ public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() 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 @@ public async Task AjaxForbidTurnsInto403WithLocationHeader() 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 @@ public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() 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 @@ public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() 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 @@ public async Task CookieNotRenewedAfterSignOut() // 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 @@ public async Task CookieUsesPathBaseByDefault() 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 @@ public async Task CanConfigureDefaultCookieInstance() 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 @@ public async Task CanConfigureNamedCookieInstance() 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 1529dc803..fc73325e0 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 b37ae53d5..a1e58743b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -28,7 +28,7 @@ public void CanRoundTripEmptyPrincipal() 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 @@ public void CanRoundTripBootstrapContext() 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 @@ public void CanRoundTripActorIdentity() 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 @@ public void CanRoundTripClaimProperties() 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 05e5708de..4d4023bee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -48,7 +48,7 @@ public void SubsequentStoreTokenDeletesPreviousTokens() 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 714b26c7e..3eefb7af7 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -40,12 +40,12 @@ public async Task CanCombineAuthorizeAttributes() // 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 @@ public async Task CanReplaceDefaultPolicy() // 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 @@ public async Task CombineMustTrimRoles() 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 @@ public async Task CombineMustTrimAuthenticationScheme() // 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 @@ public async Task CombineMustIgnoreEmptyAuthenticationScheme() // 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 @@ public async Task CombineMustIgnoreEmptyRoles() 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 b14ea0d74..769adc015 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -35,7 +35,7 @@ public void NewSerializerCanReadInteropTicket() 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 438/611] 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 965ca5fdb..78b63bb38 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs @@ -31,10 +31,10 @@ public ClaimAction(string claimType, string valueType) 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 3380f64b1..9773ebbcc 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -30,7 +30,7 @@ public class DefaultAuthorizationService : IAuthorizationService /// 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 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, /// 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 @@ private static string GetClaimValue(IIdentity identity, string claimsType) /// 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 32af74607..8976425ba 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -43,7 +43,7 @@ public interface IAuthorizationService /// /// 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 60fd66b85..6f0b8293f 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -7,7 +7,7 @@ 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 439/611] 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 d1d09f074..812ba2f1a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,7 +142,7 @@ public async Task AuthenticateAsync() 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 d346c68d7..789f5ede9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1325,11 +1325,11 @@ private static void Describe(HttpResponse res, AuthenticateResult result) 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 440/611] 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 c0663295c..1f7ecc718 100644 --- a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs +++ b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs @@ -13,7 +13,7 @@ public static class Base64UrlTextEncoder /// 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 @@ public static string Encode(byte[] data) /// 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 441/611] 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 | 11 ++--------- 31 files changed, 50 insertions(+), 92 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 ea940214e..e28500d6b 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 000000000..f75adf7e4 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/Security.sln b/Security.sln index 2e5ee56d0..811893c33 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 64438de77..52e6efb49 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 cb07f4385..5cb7e9c09 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 fe2a5fa9d..6c9bd99dc 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 cd8b6976f..9ad1abc42 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 b3d875d47..301828b01 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 d35796f75..02f214557 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 36a53b38a..a0b193b8e 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -415,7 +415,7 @@ public void Configure(IApplicationBuilder app) } 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 @@ public void Configure(IApplicationBuilder app) }); } - 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 000000000..d704a37df --- /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 712aa8177..b188a58e0 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 a9ec57199..62aee1367 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 805de682f..de8867f91 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 fe0bda164..5de668e1a 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 9437b5727..0eddc6f76 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 a15a75ee6..318c18e74 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 ae8ffd8d5..413d5d025 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 d9c5cd0b3..f720d08f0 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 8a1f97042..8f48bf685 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 83530a2be..17a027690 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 15100fbbc..01e1dd314 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 5dc2cd928..80fd59eb4 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 10a8be30f..71c07fa14 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 000000000..b9ef98116 --- /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 fc73325e0..7f3e739f3 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 6eb74aeeb..5192ee4fe 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 b578f5dcf..d75c0a47d 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 f513de4b3..96db2b38f 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 14c0aa2f1..5e1e2eb92 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 442/611] 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 e28500d6b..2490e4244 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@  - diff --git a/Directory.Build.targets b/Directory.Build.targets index f75adf7e4..bc118fd90 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 4e8a1f6de..20060c934 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 0f73dd1b4..000000000 --- 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 d4bab3eeb..7866974bc 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 52e6efb49..34af273c4 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 5cb7e9c09..6e6bd0e79 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 6c9bd99dc..2b3f9c3c9 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 9ad1abc42..64d90423b 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 301828b01..bc54cbf3d 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 02f214557..a1706f4d1 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 d704a37df..9d9a3de33 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 5de668e1a..8526fcd39 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 318c18e74..a7af0b7f3 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 413d5d025..a8f007748 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 8f48bf685..a156fa549 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 17a027690..087645ee0 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 01e1dd314..3b2ada85f 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 80fd59eb4..c6021e012 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 71c07fa14..67f8c9420 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 b9ef98116..724f34b0b 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 7f3e739f3..ae8789e11 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 5192ee4fe..b133522f0 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 d75c0a47d..49bbbd91f 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 96db2b38f..7d50d86a3 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 5e1e2eb92..779d8c141 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 443/611] 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 a3a2f2874..655da24a3 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 @@ private static readonly ResourceManager _resourceManager ///
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 690c5a280..03448b408 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 @@ private static readonly ResourceManager _resourceManager ///
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 ef1d784f2..e95b8e061 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 @@ private static readonly ResourceManager _resourceManager /// 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 618d143ee..7ef5acecb 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 @@ private static readonly ResourceManager _resourceManager /// 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 00c7b848b..5a38ade0b 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 @@ private static readonly ResourceManager _resourceManager /// 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 65a9273a0..753373ece 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 @@ private static readonly ResourceManager _resourceManager /// 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 d60c2fc73..2eabfff29 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 @@ private static readonly ResourceManager _resourceManager /// 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 11e2e4586..4f3f147e0 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -15,64 +15,56 @@ private static readonly ResourceManager _resourceManager /// 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 116001e65..c83fa9ea5 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs @@ -15,48 +15,42 @@ private static readonly ResourceManager _resourceManager /// 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 444/611] 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 c29bdeae2..54b481885 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -84,7 +84,7 @@ public virtual AuthenticationBuilder AddRemoteScheme(string 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 @@ public EnsureSignInScheme(IOptions authOptions) 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 4f3f147e0..b1941a7dc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -66,6 +66,20 @@ internal static string Exception_OptionMustBeProvided 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 54d22bcc9..9e831dc74 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 75de0652e..81373403b 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 f1038bb51..8f2cc52f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -15,10 +15,8 @@ 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 2e249a833..b2854e344 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 aeb313daa..30c33eb1d 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 74f00c8f9..d0d1c2609 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.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -46,6 +45,20 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() 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 746dfee6a..6c661af45 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 445/611] 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 e1beea7b6..38fa47857 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -85,7 +85,7 @@ public static IServiceCollection AddRemoteScheme(this IServi 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 446/611] 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 996c334a7..754c91f1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -132,7 +132,6 @@ private async Task ReadCookieTicket() } var currentUtc = Clock.UtcNow; - var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; if (expiresUtc != null && expiresUtc.Value < currentUtc) @@ -246,7 +245,7 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper _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 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) _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 bcd598364..1134566d8 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -70,7 +70,7 @@ public virtual async Task HandleRequestAsync() 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 447/611] 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 9004fc09c..db664e2ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -16,7 +16,7 @@ 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 7a2e1a2d1..155691a4b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -16,7 +16,7 @@ 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 9cf73182b..f894a97d0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -18,7 +18,7 @@ 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 8204bf07b..f4c06300c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -13,7 +13,7 @@ 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 1e1dd08d8..e8a961df3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -19,7 +19,7 @@ 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 448/611] 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 38fa47857..b274eaace 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -46,7 +46,7 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se 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 @@ public static IServiceCollection AddScheme(this IServiceColl 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 449/611] 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 811893c33..f88d8576b 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 450/611] #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 d8467be8d..2a48d250b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -38,6 +38,11 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents /// 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 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents 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 458cfd73e..224af87b6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -9,6 +9,8 @@ internal static class LoggingExtensions { 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 @@ static LoggingExtensions() 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 @@ public static void RedirectToIdentityProviderHandledResponse(this ILogger logger _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 65e1e1951..bf365ceca 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -122,6 +122,10 @@ protected virtual async Task HandleRemoteSignOutAsync() 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 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) /// 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)) + { + properties = Options.StateDataFormat.Unprotect(message.State); + } + + var signOut = new RemoteSignOutContext(Context, Scheme, Options, message) { - var properties = Options.StateDataFormat.Unprotect(protectedState); - if (!string.IsNullOrEmpty(properties?.RedirectUri)) + 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 1134566d8..4051ee666 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -93,6 +93,10 @@ public virtual async Task HandleRequestAsync() { 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 ed20d2f5a..f3fc26187 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.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 @@ public class OpenIdConnectEventTests 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 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() { 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 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() { 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 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { 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 @@ public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() 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 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsR 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 @@ public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketRece 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 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived 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 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() 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 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsR 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 @@ public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketRece 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 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun 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 @@ public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceiv 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 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( 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 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( 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 @@ public async Task OnRemoteFailure_Skip_NoMoreEventsRun() 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 @@ public async Task OnRemoteFailure_Handled_NoMoreEventsRun() 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 @@ public async Task OnTicketReceived_Skip_NoMoreEventsRun() 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 @@ public async Task OnTicketReceived_Handled_NoMoreEventsRun() 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 @@ public async Task OnTicketReceived_Handled_NoMoreEventsRun() 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 @@ private class TestStateDataFormat : ISecureDataFormat public string Protect(AuthenticationProperties data) { - throw new NotImplementedException(); + return "protected_state"; } public string Protect(AuthenticationProperties data, string purpose) @@ -1879,11 +1874,13 @@ public string Protect(AuthenticationProperties data, string purpose) 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 451/611] Update API check baselines to 2.0 --- .../baseline.netcore.json | 1348 ++++---- .../breakingchanges.netcore.json | 47 - .../baseline.netcore.json | 399 +-- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 261 +- .../breakingchanges.netcore.json | 40 - .../baseline.netcore.json | 374 +-- .../breakingchanges.netcore.json | 43 - .../baseline.netcore.json | 219 +- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 1481 ++++++--- .../breakingchanges.netcore.json | 35 - .../baseline.netcore.json | 1549 +++++---- .../breakingchanges.netcore.json | 68 - .../baseline.netcore.json | 394 +-- .../breakingchanges.netcore.json | 45 - .../baseline.netcore.json | 2960 ++++++++--------- .../breakingchanges.netcore.json | 116 - .../baseline.netcore.json | 211 ++ .../baseline.netcore.json | 386 ++- .../baseline.netcore.json | 26 +- .../baseline.netframework.json | 5 +- 22 files changed, 5377 insertions(+), 4668 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 56e48d3fe..1f1115460 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,8 +1,8 @@ { - "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.AspNetCore.Builder.CookieAppBuilderExtensions", + "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -12,14 +12,14 @@ "Members": [ { "Kind": "Method", - "Name": "UseCookieAuthentication", + "Name": "AddCookie", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, "Extension": true, "Visibility": "Public", @@ -27,281 +27,396 @@ }, { "Kind": "Method", - "Name": "UseCookieAuthentication", + "Name": "AddCookie", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "authenticationScheme", + "Type": "System.String" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "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", + "Name": "AddCookie", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookieDomain", - "Parameters": [], - "ReturnType": "System.String", + "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": "set_CookieDomain", + "Name": "AddCookie", "Parameters": [ { - "Name": "value", + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_CookiePath", - "Parameters": [], - "ReturnType": "System.String", + "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": "set_CookiePath", + "Name": "UseCookieAuthentication", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { - "Kind": "Method", - "Name": "get_CookieHttpOnly", + "Kind": "Field", + "Name": "CookiePrefix", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_CookieHttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_CookieSecure", + "Kind": "Field", + "Name": "LogoutPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_CookieSecure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_DataProtectionProvider", + "Kind": "Field", + "Name": "ReturnUrlParameter", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_DataProtectionProvider", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, "Visibility": "Public", - "GenericParameter": [] - }, + "GenericParameter": [], + "Constant": true, + "Literal": "\"Cookies\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" + ], + "Members": [ { "Kind": "Method", - "Name": "get_ExpireTimeSpan", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ExpireTimeSpan", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.TimeSpan" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_SlidingExpiration", + "Name": "InitializeHandlerAsync", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SlidingExpiration", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_LoginPath", + "Name": "HandleAuthenticateAsync", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_LoginPath", + "Name": "FinishResponseAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "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_LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "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": "set_LogoutPath", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "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_AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", + "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": "set_AccessDeniedPath", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "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" } ], - "ReturnType": "System.Void", "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_ReturnUrlParameter", + "Name": "get_Cookie", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ReturnUrlParameter", + "Name": "set_Cookie", "Parameters": [ { "Name": "value", - "Type": "System.String" + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -310,19 +425,19 @@ }, { "Kind": "Method", - "Name": "get_Events", + "Name": "get_DataProtectionProvider", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "set_DataProtectionProvider", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" } ], "ReturnType": "System.Void", @@ -331,19 +446,19 @@ }, { "Kind": "Method", - "Name": "get_TicketDataFormat", + "Name": "get_SlidingExpiration", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TicketDataFormat", + "Name": "set_SlidingExpiration", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Type": "System.Boolean" } ], "ReturnType": "System.Void", @@ -352,19 +467,19 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_LoginPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_LoginPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "ReturnType": "System.Void", @@ -373,19 +488,19 @@ }, { "Kind": "Method", - "Name": "get_CookieManager", + "Name": "get_LogoutPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieManager", + "Name": "set_LogoutPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "ReturnType": "System.Void", @@ -394,58 +509,40 @@ }, { "Kind": "Method", - "Name": "get_SessionStore", + "Name": "get_AccessDeniedPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SessionStore", + "Name": "set_AccessDeniedPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "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", + "Name": "get_ReturnUrlParameter", "Parameters": [], - "ReturnType": "System.Nullable", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ChunkSize", + "Name": "set_ReturnUrlParameter", "Parameters": [ { "Name": "value", - "Type": "System.Nullable" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -454,19 +551,19 @@ }, { "Kind": "Method", - "Name": "get_ThrowForPartialCookies", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ThrowForPartialCookies", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Boolean" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", @@ -475,367 +572,197 @@ }, { "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_TicketDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AppendResponseCookie", + "Name": "set_TicketDataFormat", "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.Authentication.ISecureDataFormat" } ], "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", + "Name": "get_CookieManager", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, + "Kind": "Method", + "Name": "set_CookieManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "ReturnUrlParameter", + "Kind": "Method", + "Name": "get_SessionStore", "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", "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", + "Name": "set_SessionStore", "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" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" } ], + "ReturnType": "System.Void", "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", + "Name": "get_ExpireTimeSpan", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AppendResponseCookie", + "Name": "set_ExpireTimeSpan", "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": "System.TimeSpan" } ], "ReturnType": "System.Void", + "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", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "StoreAsync", + "Name": "set_CookieName", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RenewAsync", + "Name": "get_CookieDomain", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieDomain", "Parameters": [ { - "Name": "key", + "Name": "value", "Type": "System.String" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RetrieveAsync", + "Name": "get_CookiePath", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookiePath", "Parameters": [ { - "Name": "key", + "Name": "value", "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoveAsync", + "Name": "get_CookieHttpOnly", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieHttpOnly", "Parameters": [ { - "Name": "key", - "Type": "System.String" + "Name": "value", + "Type": "System.Boolean" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_CookieSecure", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_CookieSecure", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" } ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -846,9 +773,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -938,7 +863,7 @@ "Kind": "Method", "Name": "get_OnRedirectToLogin", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -948,7 +873,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -959,7 +884,7 @@ "Kind": "Method", "Name": "get_OnRedirectToAccessDenied", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -969,7 +894,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -980,7 +905,7 @@ "Kind": "Method", "Name": "get_OnRedirectToLogout", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -990,7 +915,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -1001,7 +926,7 @@ "Kind": "Method", "Name": "get_OnRedirectToReturnUrl", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -1011,7 +936,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -1029,7 +954,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1044,7 +968,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1059,7 +982,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1074,7 +996,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1084,12 +1005,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1099,12 +1019,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1114,12 +1033,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1129,12 +1047,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1148,100 +1065,13 @@ ], "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", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", "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", @@ -1251,12 +1081,8 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "principal", @@ -1264,7 +1090,11 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], "Visibility": "Public", @@ -1277,59 +1107,9 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", "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", @@ -1360,12 +1140,12 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" }, { "Name": "principal", @@ -1373,7 +1153,7 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "cookieOptions", @@ -1390,7 +1170,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { @@ -1414,27 +1194,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", @@ -1443,13 +1202,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "cookieOptions", @@ -1465,26 +1228,10 @@ { "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": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", "Name": "get_ShouldRenew", @@ -1536,12 +1283,16 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], "Visibility": "Public", @@ -1551,7 +1302,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "Kind": "Interface", "Abstract": true, @@ -1559,47 +1310,97 @@ "Members": [ { "Kind": "Method", - "Name": "ValidatePrincipal", + "Name": "GetRequestCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.String", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SigningIn", + "Name": "AppendResponseCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignedIn", + "Name": "DeleteCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + "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", + "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": "RedirectToLogout", + "Name": "RenewAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Name": "key", + "Type": "System.String" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], "ReturnType": "System.Threading.Tasks.Task", @@ -1607,55 +1408,216 @@ }, { "Kind": "Method", - "Name": "RedirectToLogin", + "Name": "RetrieveAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "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.PostConfigureCookieAuthenticationOptions", + "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.Cookies.CookieAuthenticationOptions" + } + ], + "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": [] + }, + { + "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": "RedirectToReturnUrl", + "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.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAccessDenied", + "Name": "AppendResponseCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "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": "SigningOut", + "Name": "DeleteCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + "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": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", "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 91781d2dd..000000000 --- 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 1e070fc7f..82a48a6bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,61 +1,8 @@ { - "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.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", + "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -65,308 +12,171 @@ "Members": [ { "Kind": "Method", - "Name": "GetId", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetAgeRangeMin", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMax", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetBirthday", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFirstName", - "Parameters": [ + "Name": "authenticationScheme", + "Type": "System.String" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetGender", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLastName", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLink", - "Parameters": [ + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { - "Kind": "Method", - "Name": "GetLocation", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetLocale", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetMiddleName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetTimeZone", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Facebook\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "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 f64e6b834..000000000 --- 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 647633afa..61aae649d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,8 +1,8 @@ { - "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.AspNetCore.Authentication.Google.GoogleDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,51 +11,94 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "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": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "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": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "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, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "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": [], - "Constant": true, - "Literal": "\"Google\"" + "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -64,75 +107,68 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetFamilyName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetProfile", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] - }, + "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": "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": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_AccessType", "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" + "Name": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "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 db3d1fcf0..000000000 --- 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 37e18e53e..997cf7bdf 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,104 +11,86 @@ "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\"" - } - ], - "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", + "Kind": "Method", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], - "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", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Exception", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "value", - "Type": "System.Exception" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "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": [] } @@ -116,33 +98,45 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "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": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -150,58 +144,51 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "MessageReceived", + "Name": "set_Exception", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + "Name": "value", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "TokenValidated", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", "GenericParameter": [] } ], @@ -211,17 +198,9 @@ "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", - "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", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", "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 223ff401b..000000000 --- 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 06b3cd0d5..5791297b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,8 +1,8 @@ { - "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.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,51 +11,94 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "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": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "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": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "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, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "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": [], - "Constant": true, - "Literal": "\"Microsoft\"" + "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -64,124 +107,70 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetDisplayName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetSurname", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Microsoft\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "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 66f2a77b4..000000000 --- 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 d485aedb1..ffda3cbaf 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": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "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,60 +888,43 @@ "ParameterPosition": 0, "New": true, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "Visibility": "Public", "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "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, + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Response", + "Name": "get_ClientId", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Response", + "Name": "set_ClientId", "Parameters": [ { "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -257,7 +933,7 @@ }, { "Kind": "Method", - "Name": "get_AccessToken", + "Name": "get_ClientSecret", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -265,7 +941,7 @@ }, { "Kind": "Method", - "Name": "set_AccessToken", + "Name": "set_ClientSecret", "Parameters": [ { "Name": "value", @@ -278,7 +954,7 @@ }, { "Kind": "Method", - "Name": "get_TokenType", + "Name": "get_AuthorizationEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -286,7 +962,7 @@ }, { "Kind": "Method", - "Name": "set_TokenType", + "Name": "set_AuthorizationEndpoint", "Parameters": [ { "Name": "value", @@ -299,7 +975,7 @@ }, { "Kind": "Method", - "Name": "get_RefreshToken", + "Name": "get_TokenEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -307,7 +983,7 @@ }, { "Kind": "Method", - "Name": "set_RefreshToken", + "Name": "set_TokenEndpoint", "Parameters": [ { "Name": "value", @@ -320,7 +996,7 @@ }, { "Kind": "Method", - "Name": "get_ExpiresIn", + "Name": "get_UserInformationEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -328,7 +1004,7 @@ }, { "Kind": "Method", - "Name": "set_ExpiresIn", + "Name": "set_UserInformationEndpoint", "Parameters": [ { "Name": "value", @@ -341,150 +1017,121 @@ }, { "Kind": "Method", - "Name": "get_Error", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Error", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Exception" + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents" } ], "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", + "Name": "get_ClaimActions", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenResponse", + "Name": "get_Scope", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "ReturnType": "System.Collections.Generic.ICollection", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_AccessToken", + "Name": "get_StateDataFormat", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_RefreshToken", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.Nullable", + "Name": "Success", + "Parameters": [ + { + "Name": "response", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", + "Name": "Failed", + "Parameters": [ + { + "Name": "error", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Ticket", + "Name": "get_Response", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "Newtonsoft.Json.Linq.JObject", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Ticket", + "Name": "set_Response", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Type": "Newtonsoft.Json.Linq.JObject" } ], "ReturnType": "System.Void", @@ -493,99 +1140,40 @@ }, { "Kind": "Method", - "Name": "get_Identity", + "Name": "get_AccessToken", "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsIdentity", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_AccessToken", "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": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", "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", + "Name": "get_TokenType", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnCreatingTicket", + "Name": "set_TokenType", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -594,19 +1182,19 @@ }, { "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", + "Name": "get_RefreshToken", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", + "Name": "set_RefreshToken", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -615,38 +1203,43 @@ }, { "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", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", + "Name": "set_ExpiresIn", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "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": [] } @@ -654,23 +1247,23 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", + "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", + "Name": "get_ClaimType", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_RedirectUri", + "Name": "get_ValueType", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -678,79 +1271,40 @@ }, { "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "Run", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" }, { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" }, { - "Name": "redirectUri", + "Name": "issuer", "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, + "ReturnType": "System.Void", + "Virtual": true, + "Abstract": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseOAuthAuthentication", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "valueType", + "Type": "System.String" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -758,26 +1312,27 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], + "ImplementedInterfaces": [ + "System.Collections.Generic.IEnumerable" + ], "Members": [ { "Kind": "Method", - "Name": "get_ClientId", + "Name": "Clear", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ClientId", + "Name": "Remove", "Parameters": [ { - "Name": "value", + "Name": "claimType", "Type": "System.String" } ], @@ -787,19 +1342,11 @@ }, { "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", + "Name": "Add", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "action", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction" } ], "ReturnType": "System.Void", @@ -808,148 +1355,256 @@ }, { "Kind": "Method", - "Name": "get_AuthorizationEndpoint", + "Name": "GetEnumerator", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Collections.Generic.IEnumerator", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.Collections.Generic.IEnumerable", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_AuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", + "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_TokenEndpoint", + "Name": "get_Resolver", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TokenEndpoint", + "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", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "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": "set_UserInformationEndpoint", + "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", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + "Name": "claimType", + "Type": "System.String" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Scope", + "Name": "get_JsonKey", "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "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": "Method", - "Name": "set_StateDataFormat", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonSubKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_SubKey", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "Run", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "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": [], + "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 3124d7fe7..000000000 --- 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 64cb79487..9623b214e 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,200 +11,132 @@ "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", + "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": "CookieNoncePrefix", - "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": "RedirectUriForCodePropertiesKey", - "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": "UserstatePropertiesKey", - "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": "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", + "Abstract": true, + "Static": true, + "Sealed": true, "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", + "Name": "UseOpenIdConnectAuthentication", "Parameters": [ { - "Name": "tokenEndpointRequest", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "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", + "Name": "UseOpenIdConnectAuthentication", "Parameters": [ { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" } ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -212,75 +144,61 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.ClaimActionCollectionUniqueExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Abstract": true, + "Static": true, + "Sealed": true, "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", + "Name": "MapUniqueJsonKey", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" }, { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, + "Name": "jsonKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapUniqueJsonKey", + "Parameters": [ { - "Name": "services", - "Type": "System.IServiceProvider" + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "jsonKey", + "Type": "System.String" }, { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" + "Name": "valueType", + "Type": "System.String" } ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -288,36 +206,33 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "RedirectGet", + "Kind": "Method", + "Name": "get_ProtocolMessage", "Parameters": [], - "GenericParameter": [], - "Literal": "0" + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] }, { - "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": "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,35 +450,48 @@ "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", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ProtocolMessage", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Token", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ProtocolMessage", + "Name": "set_Token", "Parameters": [ { "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -566,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", @@ -578,147 +526,174 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthorizationCodeReceived", + "Name": "set_OnAuthenticationFailed", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_OnAuthorizationCodeReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProvider", + "Name": "set_OnAuthorizationCodeReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoteSignOut", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenResponseReceived", + "Name": "get_OnRedirectToIdentityProviderForSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProviderForSignOut", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenValidated", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UserInformationReceived", + "Name": "get_OnTokenResponseReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenResponseReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "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", + "Name": "get_OnTokenValidated", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Token", + "Name": "set_OnTokenValidated", "Parameters": [ { "Name": "value", - "Type": "System.String" + "Type": "System.Func" } ], "ReturnType": "System.Void", @@ -727,19 +702,19 @@ }, { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_OnUserInformationReceived", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Properties", + "Name": "set_OnUserInformationReceived", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "System.Func" } ], "ReturnType": "System.Void", @@ -747,153 +722,163 @@ "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AuthenticationFailed", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" } ], - "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", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnAuthenticationFailed", + "Name": "AuthorizationCodeReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnAuthorizationCodeReceived", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnAuthorizationCodeReceived", + "Name": "RedirectToIdentityProvider", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" } ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnMessageReceived", + "Name": "RedirectToIdentityProviderForSignOut", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnRedirectToIdentityProvider", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToIdentityProvider", + "Name": "TokenResponseReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnRedirectToIdentityProviderForSignOut", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToIdentityProviderForSignOut", + "Name": "UserInformationReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "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.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnRemoteSignOut", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRemoteSignOut", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -902,61 +887,124 @@ }, { "Kind": "Method", - "Name": "get_OnTokenResponseReceived", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTokenResponseReceived", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnTokenValidated", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTokenValidated", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "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": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.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.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnUserInformationReceived", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnUserInformationReceived", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -965,194 +1013,147 @@ }, { "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", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthorizationCodeReceived", + "Name": "set_TokenEndpointResponse", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "MessageReceived", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "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", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", + "Name": "set_ProtocolMessage", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "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", + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenResponseReceived", + "Name": "set_SecurityToken", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "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", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UserInformationReceived", + "Name": "set_TokenEndpointResponse", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "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", + "Name": "get_Nonce", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_Nonce", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", "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", @@ -1161,13 +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": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1177,35 +1186,48 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", + "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_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenEndpointResponse", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "ReturnType": "Newtonsoft.Json.Linq.JObject", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TokenEndpointResponse", + "Name": "set_User", "Parameters": [ { "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "Newtonsoft.Json.Linq.JObject" } ], "ReturnType": "System.Void", @@ -1220,13 +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.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1236,202 +1266,268 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "get_Properties", + "Kind": "Field", + "Name": "AuthenticationPropertiesKey", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_SecurityToken", + "Kind": "Field", + "Name": "CookieNoncePrefix", "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "RedirectUriForCodePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", + "Kind": "Field", + "Name": "UserstatePropertiesKey", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "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": "set_TokenEndpointResponse", + "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": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Nonce", + "Name": "CreateEventsAsync", "Parameters": [], - "ReturnType": "System.String", + "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": "set_Nonce", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "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": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "HandleSignOutCallbackAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "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", + "Name": "HandleRemoteAuthenticateAsync", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_User", + "Name": "RedeemAuthorizationCodeAsync", "Parameters": [ { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "tokenEndpointRequest", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "GetUserInformationAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" }, { - "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": "jwt", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + }, { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "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 931a7b079..000000000 --- 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 c35232a31..b577f07eb 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, + "Extension": 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", + "Kind": "Method", + "Name": "AddTwitter", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "authenticationScheme", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], - "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", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "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": "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 6b8440911..000000000 --- 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 1f69da5a8..6db7d2c81 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", - "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": [] - }, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Skipped", + "Name": "get_Services", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Success", + "Name": "AddScheme", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "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": "Skip", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "Name": "AddScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "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": "Fail", + "Name": "AddRemoteScheme", "Parameters": [ { - "Name": "failure", - "Type": "System.Exception" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler" + ] + } + ] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" } ], - "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", - "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", + "Name": "get_Scheme", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationScheme", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ChallengeCalled", + "Name": "get_Options", "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,38 +224,57 @@ }, { "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": "get_OptionsMonitor", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Options.IOptionsMonitor", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_PriorHandler", + "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_CurrentUri", + "Name": "get_ClaimsIssuer", "Parameters": [], "ReturnType": "System.String", + "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_CurrentUri", "Parameters": [], - "ReturnType": "T0", + "ReturnType": "System.String", "Visibility": "Protected", "GenericParameter": [] }, @@ -659,42 +283,24 @@ "Name": "InitializeAsync", "Parameters": [ { - "Name": "options", - "Type": "T0" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "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", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "BuildRedirectUri", - "Parameters": [ - { - "Name": "targetPath", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FinishResponseAsync", + "Name": "InitializeEventsAsync", "Parameters": [], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, @@ -703,59 +309,43 @@ }, { "Kind": "Method", - "Name": "HandleRequestAsync", + "Name": "CreateEventsAsync", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "describeContext", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, + "Name": "InitializeHandlerAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ShouldHandleScheme", + "Name": "BuildRedirectUri", "Parameters": [ { - "Name": "authenticationScheme", + "Name": "targetPath", "Type": "System.String" - }, - { - "Name": "handleAutomatic", - "Type": "System.Boolean" } ], - "ReturnType": "System.Boolean", - "Visibility": "Public", + "ReturnType": "System.String", + "Visibility": "Protected", "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", @@ -779,27 +377,25 @@ }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "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", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleSignInAsync", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", @@ -809,106 +405,149 @@ }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "ChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleSignOutAsync", + "Name": "ForbidAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, "Virtual": true, - "Visibility": "Protected", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "HandleForbiddenAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "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" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, "Visibility": "Protected", "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Schemes", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider", + "Visibility": "Public", + "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleUnauthorizedAsync", + "Name": "set_Schemes", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ChallengeAsync", + "Name": "Invoke", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" } ], "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", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "schemes", + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" + } + ], + "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] + "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_AuthenticationScheme", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimsIssuer", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -916,7 +555,7 @@ }, { "Kind": "Method", - "Name": "set_AuthenticationScheme", + "Name": "set_ClaimsIssuer", "Parameters": [ { "Name": "value", @@ -929,19 +568,19 @@ }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_Events", "Parameters": [], - "ReturnType": "T0", + "ReturnType": "System.Object", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "T0" + "Type": "System.Object" } ], "ReturnType": "System.Void", @@ -950,19 +589,19 @@ }, { "Kind": "Method", - "Name": "get_Logger", + "Name": "get_EventsType", "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "ReturnType": "System.Type", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Logger", + "Name": "set_EventsType", "Parameters": [ { "Name": "value", - "Type": "Microsoft.Extensions.Logging.ILogger" + "Type": "System.Type" } ], "ReturnType": "System.Void", @@ -970,132 +609,232 @@ "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_UrlEncoder", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "set_UrlEncoder", + "Name": "Serialize", "Parameters": [ { - "Name": "value", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "model", + "Type": "T0" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Byte[]", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Invoke", + "Name": "Deserialize", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "data", + "Type": "System.Byte[]" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", + "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": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "Protect", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "data", + "Type": "T0" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" }, { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "purpose", + "Type": "System.String" } ], - "Visibility": "Protected", + "ReturnType": "T0", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TOptions", + "ParameterName": "TData", "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] + "BaseTypeOrInterfaces": [] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "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_AuthenticationScheme", + "Name": "get_Default", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "Write", "Parameters": [ { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "writer", + "Type": "System.IO.BinaryWriter" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1103,105 +842,164 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [], + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + ], "Members": [ { "Kind": "Method", - "Name": "get_Name", - "Parameters": [], + "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": "set_Name", + "Name": "Protect", "Parameters": [ { - "Name": "value", + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Value", - "Parameters": [], - "ReturnType": "System.String", + "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": "set_Value", + "Name": "Unprotect", "Parameters": [ { - "Name": "value", + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "serializer", + "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + }, + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", "Visibility": "Public", "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, "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", + "Name": "Encode", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.String", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Principal", + "Name": "Decode", "Parameters": [ { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "text", + "Type": "System.String" } ], - "ReturnType": "System.Void", + "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": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" } ], "Visibility": "Public", @@ -1211,153 +1009,156 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", + "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Microsoft.AspNetCore.Authentication.IDataSerializer" ], "Members": [ { "Kind": "Method", - "Name": "get_PriorHandler", + "Name": "get_Default", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_PriorHandler", + "Name": "Serialize", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthenticateAsync", + "Name": "Deserialize", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + "Name": "data", + "Type": "System.Byte[]" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ChallengeAsync", + "Name": "Write", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "System.Void", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetDescriptions", + "Name": "WriteIdentity", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" } ], "ReturnType": "System.Void", - "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "WriteClaim", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "System.Void", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "Read", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RegisterAuthenticationHandler", + "Name": "ReadIdentity", "Parameters": [ { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UnregisterAuthenticationHandler", + "Name": "ReadClaim", "Parameters": [ { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "transform", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - }, - { - "Name": "httpContext", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1365,42 +1166,49 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "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": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "ReturnType": "T0", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "System.Void", + "Name": "get_HttpContext", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "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": [] }, @@ -1409,212 +1217,197 @@ "Name": ".ctor", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "T0" } ], - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_OnTransform", + "Name": "get_Result", "Parameters": [], - "ReturnType": "System.Func>", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTransform", + "Name": "set_Result", "Parameters": [ { "Name": "value", - "Type": "System.Func>" + "Type": "Microsoft.AspNetCore.Authentication.HandleRequestResult" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "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", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "SkipHandler", "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { - "Kind": "Method", - "Name": "TransformAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], - "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + "GenericParameters": [ { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "GenericParameter": [] + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } - ], - "GenericParameters": [] + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Name": "Microsoft.AspNetCore.Authentication.PrincipalContext", "Visibility": "Public", "Kind": "Class", "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "HandleRequestAsync", + "Name": "get_Principal", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Security.Claims.ClaimsPrincipal", "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", + "Name": "set_Principal", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", "Virtual": true, - "Override": true, - "Visibility": "Protected", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "HandleSignInAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "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", - "Virtual": true, - "Override": true, "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": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Virtual": true, - "Override": true, - "Visibility": "Protected", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GenerateCorrelationId", + "Name": "set_Properties", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -1623,23 +1416,26 @@ "GenericParameter": [] }, { - "Kind": "Method", - "Name": "ValidateCorrelationId", + "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.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], "Visibility": "Protected", "GenericParameter": [] } @@ -1649,20 +1445,21 @@ "ParameterName": "TOptions", "ParameterPosition": 0, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Name": "Microsoft.AspNetCore.Authentication.RedirectContext", "Visibility": "Public", "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_SignInScheme", + "Name": "get_RedirectUri", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -1670,7 +1467,7 @@ }, { "Kind": "Method", - "Name": "set_SignInScheme", + "Name": "set_RedirectUri", "Parameters": [ { "Name": "value", @@ -1684,277 +1481,243 @@ { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "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" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], "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": [] - }, + "GenericParameters": [ { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } - ], - "GenericParameters": [] + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "StoreTokens", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "System.Collections.Generic.IEnumerable" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], "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_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokens", + "Name": "set_Properties", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", + "Virtual": 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, + "Name": "Success", + "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokenAsync", + "Name": "Fail", "Parameters": [ { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "signInScheme", - "Type": "System.String" - }, - { - "Name": "tokenName", - "Type": "System.String" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "Serialize", + "Name": "Fail", "Parameters": [ { - "Name": "model", - "Type": "T0" + "Name": "failureMessage", + "Type": "System.String" } ], - "ReturnType": "System.Byte[]", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Deserialize", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "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" } ], - "ReturnType": "T0", + "Visibility": "Protected", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TModel", + "ParameterName": "TOptions", "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "Protect", + "Name": "get_OnRemoteFailure", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteFailure", "Parameters": [ { - "Name": "data", - "Type": "T0" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.String", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Protect", + "Name": "get_OnTicketReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTicketReceived", "Parameters": [ { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.String", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "RemoteFailure", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RemoteFailureContext" } ], - "ReturnType": "T0", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "TicketReceived", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" } ], - "ReturnType": "T0", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", "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" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1962,171 +1725,157 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Name": "Microsoft.AspNetCore.Authentication.RemoteFailureContext", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Default", + "Name": "get_Failure", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Static": true, + "ReturnType": "System.Exception", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Serialize", + "Name": "set_Failure", "Parameters": [ { - "Name": "model", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "System.Exception" } ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Deserialize", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "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" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ResultContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Read", + "Name": "set_Principal", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "get_Properties", "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - ], - "Members": [ + }, { "Kind": "Method", - "Name": "Protect", + "Name": "set_Properties", "Parameters": [ { - "Name": "data", - "Type": "T0" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "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", + "Name": "get_Result", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "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": "protectedText", - "Type": "System.String" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "Fail", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", + "Name": "failureMessage", "Type": "System.String" } ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, @@ -2135,60 +1884,81 @@ "Name": ".ctor", "Parameters": [ { - "Name": "serializer", - "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TData", + "ParameterName": "TOptions", "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", + "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "Encode", + "Name": "get_ReturnUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUri", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.String", - "Static": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Decode", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "text", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Byte[]", - "Static": true, "Visibility": "Public", "GenericParameter": [] } @@ -2196,170 +1966,149 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Kind": "Interface", + "Abstract": true, "ImplementedInterfaces": [], "Members": [ { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", "Visibility": "Public", "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" + "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" ], "Members": [ { "Kind": "Method", - "Name": "get_Default", + "Name": "get_SignInScheme", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.String", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Serialize", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" } ], - "ReturnType": "System.Byte[]", + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Name": "ShouldHandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "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", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "Abstract": 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", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "Override": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Read", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ReadIdentity", + "Name": "GenerateCorrelationId", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", + "ReturnType": "System.Void", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ReadClaim", + "Name": "ValidateCorrelationId", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Security.Claims.Claim", + "ReturnType": "System.Boolean", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] @@ -2367,81 +2116,113 @@ { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", + "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": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.BaseContext", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_HttpContext", + "Name": "Validate", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Request", + "Name": "get_BackchannelTimeout", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "ReturnType": "System.TimeSpan", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Response", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "ReturnType": "System.Net.Http.HttpMessageHandler", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" } ], - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_State", + "Name": "get_Backchannel", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", + "ReturnType": "System.Net.Http.HttpClient", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_State", + "Name": "set_Backchannel", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.EventResultState" + "Type": "System.Net.Http.HttpClient" } ], "ReturnType": "System.Void", @@ -2450,51 +2231,61 @@ }, { "Kind": "Method", - "Name": "get_HandledResponse", + "Name": "get_DataProtectionProvider", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", + "Name": "set_DataProtectionProvider", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleResponse", + "Name": "get_CallbackPath", "Parameters": [], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SkipToNextMiddleware", - "Parameters": [], + "Name": "set_CallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Ticket", + "Name": "get_SignInScheme", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Ticket", + "Name": "set_SignInScheme", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -2503,86 +2294,40 @@ }, { "Kind": "Method", - "Name": "CheckEventResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Direction": "Out" - } - ], - "ReturnType": "System.Boolean", + "Name": "get_RemoteAuthenticationTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_RemoteAuthenticationTimeout", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "value", + "Type": "System.TimeSpan" } ], - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "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", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Failure", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Exception" + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" } ], "ReturnType": "System.Void", @@ -2590,135 +2335,166 @@ "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "failure", - "Type": "System.Exception" - } - ], + "Kind": "Method", + "Name": "get_SaveTokens", + "Parameters": [], + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "RemoteFailure", + "Name": "set_SaveTokens", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + "Name": "value", + "Type": "System.Boolean" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TicketReceived", + "Name": "get_CorrelationCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CorrelationCookie", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "ImplementedInterfaces": [], "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", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnTicketReceived", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTicketReceived", + "Name": "Success", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoteFailure", + "Name": "Fail", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TicketReceived", + "Name": "Fail", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + "Name": "failureMessage", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "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.IRemoteAuthenticationEvents", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", "Visibility": "Public", "GenericParameter": [] }, @@ -2733,165 +2509,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Name": "Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "BaseType": "Microsoft.AspNetCore.Http.CookieBuilder", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Principal", + "Name": "get_AdditionalPath", "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Principal", + "Name": "Build", "Parameters": [ { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "expiresFrom", + "Type": "System.DateTimeOffset" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_Properties", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "set_Properties", + "Name": "UseAuthentication", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", + "Name": "AddAuthentication", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "defaultScheme", + "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ReturnUri", - "Parameters": [], - "ReturnType": "System.String", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ReturnUri", + "Name": "AddScheme", "Parameters": [ { - "Name": "value", + "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": "System.Void", + "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": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddScheme", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Name": "authenticationScheme", + "Type": "System.String" }, { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "configureOptions", + "Type": "System.Action" } ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, { "Kind": "Method", - "Name": "AddAuthentication", + "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": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { "Kind": "Method", - "Name": "AddAuthentication", + "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" + "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.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 81dc1133e..000000000 --- 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 000000000..0bad3ed62 --- /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 8ae585270..6108db6d2 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, @@ -902,7 +1036,7 @@ }, { "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", + "Name": "set_AuthenticationSchemes", "Parameters": [ { "Name": "value", @@ -916,6 +1050,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -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 8eef347eb..97da7ea5c 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 1fc242ec5..a55bf8f33 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 452/611] #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 | 113 ++++++++----- 11 files changed, 344 insertions(+), 176 deletions(-) rename src/Microsoft.AspNetCore.Authentication/{RemoteAuthenticationResult.cs => HandleRequestResult.cs} (72%) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index a0b193b8e..35896e84b 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -67,6 +67,10 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) 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 @@ public void ConfigureServices(IServiceCollection services) o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { + OnRemoteFailure = HandleOnRemoteFailure, OnCreatingTicket = async context => { // Get the GitHub user @@ -198,6 +209,30 @@ public void ConfigureServices(IServiceCollection services) }); } + 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 007d7dbef..80680a7cf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -44,9 +44,22 @@ public OAuthHandler(IOptionsMonitor options, ILoggerFactory logger, Ur 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 @@ protected override async Task HandleRemoteAuthenticateAsync 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 @@ protected override async Task HandleRemoteAuthenticateAsync } 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 bf365ceca..7f65afdce 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -491,13 +491,10 @@ protected override async Task HandleRemoteAuthenticateAsync 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 @@ protected override async Task HandleRemoteAuthenticateAsync 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 @@ protected override async Task HandleRemoteAuthenticateAsync // 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 @@ protected override async Task HandleRemoteAuthenticateAsync // 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,8 +716,25 @@ protected override async Task HandleRemoteAuthenticateAsync 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) @@ -830,7 +841,7 @@ protected virtual async Task GetUserInformationAsync( } 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 e8a961df3..acfd765d9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,6 @@ public TwitterHandler(IOptionsMonitor options, ILoggerFactory lo protected override async Task HandleRemoteAuthenticateAsync() { - AuthenticationProperties properties = null; var query = Request.Query; var protectedRequestToken = Request.Cookies[Options.StateCookie.Name]; @@ -57,25 +56,25 @@ protected override async Task HandleRemoteAuthenticateAsync 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 becdfb543..6b3598f40 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs @@ -25,5 +25,10 @@ public RemoteFailureContext( /// 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 8bcd2be01..3f6c2d917 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -49,13 +49,31 @@ public class HandleRequestResult : AuthenticateResult /// /// Indicates that there was a failure during authentication. /// - /// The failure message. + /// The failure exception. + /// Additional state values for the authentication session. /// The result. - public static new HandleRequestResult Fail(string failureMessage) + public static new HandleRequestResult Fail(Exception failure, AuthenticationProperties properties) { - return new HandleRequestResult() { Failure = new Exception(failureMessage) }; + 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) + => 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. /// The caller is responsible for generating the full response. diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 4051ee666..bea4895d6 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -49,6 +49,7 @@ public virtual async Task HandleRequestAsync() AuthenticationTicket ticket = null; Exception exception = null; + AuthenticationProperties properties = null; try { var authResult = await HandleRemoteAuthenticateAsync(); @@ -66,8 +67,8 @@ public virtual async Task HandleRequestAsync() } 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 @@ public virtual async Task HandleRequestAsync() 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 @@ public virtual async Task HandleRequestAsync() } 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 @@ public virtual async Task HandleRequestAsync() { 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 8f2cc52f9..51bc67cc3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -253,6 +253,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => @@ -263,7 +264,8 @@ public async Task ReplyPathWithErrorFails(bool redirect) } } : 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 @@ private static TestServer CreateServer(Action configureOptions, F }); 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 30c33eb1d..81d2360ec 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.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 @@ public class OAuthTests 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 @@ public async Task VerifySchemeDefaults() public async Task ThrowsIfClientIdMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; @@ -62,22 +56,14 @@ public async Task ThrowsIfClientIdMissing() 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 @@ public async Task ThrowsIfClientSecretMissing() 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 @@ public async Task ThrowsIfCallbackPathMissing() 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 @@ public async Task ThrowsIfTokenEndpointMissing() 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 @@ public async Task ThrowsIfAuthorizationEndpointMissing() 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 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB 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 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOverriden() { var server = CreateServer( - app => { }, s => s.AddAuthentication().AddOAuth( "Weblie", opt => @@ -214,9 +167,9 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv 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 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv 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 @@ private static TestServer CreateServer(Action configure, Ac .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 f3fc26187..87bdc3f3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -95,7 +95,7 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() 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 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() 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 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() 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 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() 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 @@ public async Task OnRemoteFailure_Handled_NoMoreEventsRun() { 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 @@ public AuthenticationProperties Unprotect(string protectedText) 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 6c661af45..735cb3314 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.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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }; 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 @@ public async Task ForbidThrows() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] public async Task ChallengeWillTriggerRedirection() { @@ -178,35 +165,70 @@ public async Task ChallengeWillTriggerRedirection() o.ConsumerSecret = "Test Consumer Secret"; o.BackchannelHttpHandler = new TestHttpMessageHandler { - Sender = req => + Sender = BackchannelRequestToken + }; + }, + 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); + } + + [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 => { - 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; + 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; } }; }, - context => - { - // REVIEW: gross - context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); - return true; - }); + 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) + private static TestServer CreateServer(Action options, Func> handler = null) { var builder = new WebHostBuilder() .Configure(app => @@ -228,7 +250,7 @@ private static TestServer CreateServer(Action options, Func(() => context.ForbidAsync("Twitter")); } - else if (handler == null || !handler(context)) + else if (handler == null || ! await handler(context)) { await next(); } @@ -247,5 +269,20 @@ private static TestServer CreateServer(Action options, Func Date: Thu, 28 Sep 2017 22:03:52 +0100 Subject: [PATCH 453/611] 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 7f65afdce..0b2419e2a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -349,6 +349,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 a8545e35a..e589a2bc8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -209,6 +209,11 @@ public override void Validate() /// 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 454/611] 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 db664e2ee..0f83c1719 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -37,7 +37,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 155691a4b..091896f7c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,7 +34,7 @@ protected override async Task CreateTicketAsync( 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 f4c06300c..bba547277 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -27,7 +27,7 @@ protected override async Task CreateTicketAsync(ClaimsIden 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 455/611] 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 143e1d254..69ead8fa6 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -17,7 +17,7 @@ public void AppendLargeCookie_Appended() 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 456/611] 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 bf9df4038..458f746c4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -249,7 +249,13 @@ private void ValidateState(IDictionary actualParams, ICollection 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 457/611] 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 0b2419e2a..0f60a558a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -353,6 +353,14 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 e589a2bc8..f6d914731 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,6 +84,11 @@ public override void Validate() { 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 @@ public override void Validate() 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 fb08ae278..4ff5aa9ad 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -409,5 +409,46 @@ public async Task Challenge_WithEmptyConfig_Fails() 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 d0d1c2609..871ef9d08 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -115,6 +115,21 @@ public Task ThrowsWhenMetadataAddressIsNotHttps() ); } + [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 458f746c4..5b4ea2348 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 @@ private void ValidateParameters( 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 @@ private void ValidateVersionTelemetry(IDictionary actualParams, 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 458/611] 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 0f60a558a..330d064c0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -355,9 +355,9 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // 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 f6d914731..a40d37435 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,9 +84,9 @@ public override void Validate() { 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 @@ public override void Validate() /// 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 4ff5aa9ad..7ab81c9dd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -414,8 +414,8 @@ public async Task Challenge_WithEmptyConfig_Fails() public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() { var settings = new TestSettings( - opt => - { + opt => + { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; }); @@ -434,8 +434,8 @@ public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() 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 871ef9d08..69ba75829 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -118,7 +118,7 @@ public Task ThrowsWhenMetadataAddressIsNotHttps() [Fact] public Task ThrowsWhenMaxAgeIsNegative() { - return TestConfigurationException( + return TestConfigurationException( o => { o.SignInScheme = "TestScheme"; @@ -126,7 +126,7 @@ public Task ThrowsWhenMaxAgeIsNegative() 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 5b4ea2348..f174342ae 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 @@ private void ValidatePostLogoutRedirectUri(IDictionary actualPar 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 459/611] 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 4f85bae46..c7b6e3431 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 b6c8d2486..c0050bda1 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 11cdbe550..98a4b2276 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 000000000..d52d5c7e6 --- /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 d5eb4d5cf..49c289985 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 000000000..c278423ac --- /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 460/611] 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 54b481885..3bce55ea1 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -97,10 +97,6 @@ public EnsureSignInScheme(IOptions authOptions) 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 812ba2f1a..9728e5ff0 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -87,7 +87,7 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte 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 0e86b3a9f..18d4c9788 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -13,9 +13,14 @@ public class AuthenticationSchemeOptions /// /// 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 3b34cf43e..daba1890f 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -32,6 +32,19 @@ public RemoteAuthenticationOptions() }; } + /// + /// 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 81373403b..2314b6b3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -29,7 +29,11 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() { 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 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() { 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 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() { 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 81d2360ec..65d865b94 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -27,6 +27,9 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() 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 461/611] #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 754c91f1e..5d0afba46 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -20,7 +20,7 @@ public class CookieAuthenticationHandler : 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 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr { 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 330d064c0..7981cafd1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -32,6 +32,7 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler"; private const string HtmlFormFormat = @" @@ -261,7 +262,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) // 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // 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 462/611] #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 9b602383c..7217e70d4 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -44,7 +44,6 @@ public ChunkingCookieManager() // 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 b323258d9..1ae4f00cd 100644 --- a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -25,7 +25,6 @@ public ChunkingCookieManager() // 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 69ead8fa6..e645745b3 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -81,7 +81,8 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingEnabled_Throws() "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 463/611] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2490e4244..61b629ccc 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 464/611] 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 0f2dbd312..04c71ed1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -80,11 +80,10 @@ public CookieBuilder Cookie 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 @@ public CookieBuilder Cookie 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 465/611] 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 e628904de..ccd1a965d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs @@ -32,7 +32,22 @@ public JsonKeyClaimAction(string claimType, string valueType, string jsonKey) /// 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 000000000..541e1edf2 --- /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 466/611] Refactor OIDC event tests --- .../OpenIdConnect/OpenIdConnectEventTests.cs | 2006 ++++++----------- 1 file changed, 701 insertions(+), 1305 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 87bdc3f3c..7530b00c3 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 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() }); 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 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() }); 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 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() }); 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 => - { - 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 => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenResponseReceived = context => + { + 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 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() }); 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenValidated = context => + { + 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 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() }); 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + }; + events.OnUserInformationReceived = context => + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() + { + 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 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() }); 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() + { + 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 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() }); 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() + { + 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 => - { - 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 => + var events = new ExpectedOidcEvents() + { + 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 => - { - 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); + var events = new ExpectedOidcEvents() + { + 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 @@ public async Task OnRedirectToIdentityProviderForSignOut_Invoked() 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 @@ public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvo 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 @@ public async Task OnRemoteSignOut_Invoked() [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 @@ public async Task OnRemoteSignOut_Skip_NoSignout() 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 @@ public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() 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, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - OnSignedOutCallbackRedirect = SignedOutCallbackNotImpl, - }; - configureEvents(events); - return events; + public bool ExpectMessageReceived { get; set; } + public bool InvokedMessageReceived { get; set; } + + 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 467/611] 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 bac5b7505..d5717b3f3 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 61b629ccc..d277ef862 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 bc118fd90..e83ff95e3 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 20060c934..4e8a1f6de 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 000000000..13ed63da1 --- /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 7866974bc..598c7f5a3 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 000000000..36d805603 --- /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 000000000..bd5d51a51 --- /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 34af273c4..d8ebc437e 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 6e6bd0e79..d48038176 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 2b3f9c3c9..2880ac963 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 64d90423b..1e0a0f5e3 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 bc54cbf3d..84fb99c7b 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 a1706f4d1..7a8de5763 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 9d9a3de33..1e0980f66 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 8526fcd39..e5bae5a3d 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 a7af0b7f3..5c8a5e3a9 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 a8f007748..b7f4c1704 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 a156fa549..7e3ce4eb3 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 087645ee0..16e4aa262 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 3b2ada85f..ac4aa6c32 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 c6021e012..1a42b04dd 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 67f8c9420..a12bc6563 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 724f34b0b..19544e342 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 ae8789e11..2a43b216d 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 b133522f0..2b2cc69ba 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 49bbbd91f..e6f0b2293 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 7d50d86a3..951dac0c5 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 779d8c141..f369f1f01 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 000000000..5c4a7c32d --- /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 3c05022b7..000000000 --- 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 468/611] 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 46223d647..8cba6c0d5 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -39,7 +39,7 @@ static LoggingExtensions() 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 469/611] 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 3bce55ea1..7bf8fe96e 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -25,18 +25,10 @@ public AuthenticationBuilder(IServiceCollection services) /// 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 @@ public virtual AuthenticationBuilder AddScheme(string authen 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 @@ public virtual AuthenticationBuilder AddRemoteScheme(string 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 9728e5ff0..ef4292100 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 @@ protected HttpResponse Response 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 @@ protected virtual async Task InitializeEventsAsync() /// 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 000000000..4a023bec2 --- /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 000000000..38d819bf5 --- /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 51bc67cc3..944a4827c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -990,7 +990,7 @@ private static TestServer CreateServer(Action configureOptions, F 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 @@ private static TestServer CreateServer(Action configureOptions, F .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 000000000..a43478c94 --- /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 470/611] 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 2a43b216d..b49206567 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 471/611] 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 32be26d33..da52e0e4c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -27,7 +27,7 @@ public class OpenIdConnectTests /// /// 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 472/611] 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 d277ef862..e6771f7a8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 36d805603..95f461301 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 d8ebc437e..193137b86 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 d48038176..6241edd66 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 2880ac963..84b436581 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 1e0a0f5e3..b14b9590f 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 84fb99c7b..23e87d4f2 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 7a8de5763..a423ae21a 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 19544e342..b842a4831 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 b49206567..57fed96c0 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 f174342ae..509b85e64 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -252,7 +252,7 @@ private void ValidateState(IDictionary actualParams, ICollection 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 2b2cc69ba..d4379c3aa 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 e6f0b2293..20cd400ce 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 951dac0c5..d7a42f3ef 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 473/611] 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 e83ff95e3..894b1d0cf 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 13ed63da1..7ef0a7cf7 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 474/611] 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 e6771f7a8..adbda10ef 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 4e8a1f6de..e32bddfd5 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 000000000..c03f3ddb6 --- /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 475/611] 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 7ef0a7cf7..e02aaa262 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 598c7f5a3..62f47b7a5 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 c03f3ddb6..9feff29d0 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 95f461301..1a99066b7 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 476/611] 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 008190f51..38a75feca 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -16,7 +16,7 @@ static LoggingExtensions() _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 477/611] 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 62f47b7a5..541470c9f 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 478/611] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c289985..27dcf848f 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 c278423ac..834961fc3 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 479/611] 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 e02aaa262..450a5804b 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 1a99066b7..e7cce9300 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 480/611] 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 450a5804b..d98007d0c 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 e7cce9300..8d52a6128 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 481/611] 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 d98007d0c..9eca47a75 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 482/611] 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 f88d8576b..543b3be26 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 000000000..fb2e7d917 --- /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 000000000..12fc8ff28 --- /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 000000000..38ca6fc37 --- /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 000000000..7ce9c2d2d --- /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 7217e70d4..42cc4e2f0 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -285,6 +285,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) 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 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) 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 04c71ed1e..35017f9c4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,6 +21,7 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions 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 a40d37435..cbf6e8eab 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -74,6 +74,7 @@ public OpenIdConnectOptions() 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 86919d092..03396807e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -35,6 +35,7 @@ public TwitterOptions() 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 daba1890f..1bd3b210e 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -29,6 +29,7 @@ public RemoteAuthenticationOptions() 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 1b13251f7..bbb4899c0 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs @@ -19,5 +19,8 @@ public AppendCookieContext(HttpContext context, CookieOptions options, string na 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 92adac967..b99fed2c3 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 @@ public CookiePolicyMiddleware( 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) - { - Wrapper = new CookiesWrapper(context, options, feature); - } - - public IResponseCookies Wrapper { get; } - - public IResponseCookies Cookies - { - get - { - return Wrapper; - } - } - } - - private class CookiesWrapper : IResponseCookies - { - public CookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + public CookiesWrapperFeature(ResponseCookiesWrapper wrapper) { - Context = context; - Feature = feature; - Policy = options; + Cookies = wrapper; } - 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 1e474bfe2..cc2deaa3a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -27,6 +27,18 @@ public class CookiePolicyOptions /// 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 f0693bf71..fd79ea8d4 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs @@ -17,5 +17,8 @@ public DeleteCookieContext(HttpContext context, CookieOptions options, string na 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 000000000..fa68a3cbe --- /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 000000000..4e62d54a2 --- /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 483/611] 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 9eca47a75..f145edd9c 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 484/611] 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 f145edd9c..3540fc231 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 8d52a6128..7c2e97aa7 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 485/611] 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 acfd765d9..670e76f7e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -60,6 +60,12 @@ protected override async Task HandleRemoteAuthenticateAsync // 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 735cb3314..2a63757b9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -195,6 +195,7 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() 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 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() 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 486/611] 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 3540fc231..cdb400f90 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 487/611] 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 543b3be26..f598f34eb 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 fa68a3cbe..e05cc9466 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -82,6 +82,30 @@ public void WithdrawConsent() _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 @@ public void Append(string key, string value, CookieOptions options) 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 @@ public void Append(string key, string value, CookieOptions options) 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 4e62d54a2..3cd018e57 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -542,6 +542,91 @@ public async Task OnDeleteCookieCanSuppressCookie() 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 488/611] Update deps --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cdb400f90..bf30832e1 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 489/611] 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 7981cafd1..4f722323d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -16,7 +16,6 @@ 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 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) } 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 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } 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 490/611] 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 f894a97d0..6d5c7f5f5 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -110,7 +110,7 @@ protected override async Task HandleAuthenticateAsync() } 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 38a75feca..5c6ca088a 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 @@ static LoggingExtensions() 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 9773ebbcc..bc5d571c4 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -98,37 +98,15 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, obje 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 1d524dd74..386df85e0 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 491/611] 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 bf30832e1..1aaf7a18a 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 541470c9f..2ab5a2ae3 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 9feff29d0..5d6639333 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 7c2e97aa7..a474bc0e3 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 492/611] Updating version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d..370d5abab 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 493/611] 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 cc2deaa3a..32d047297 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -30,7 +30,7 @@ public class CookiePolicyOptions 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 3cd018e57..4e35c165f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -221,6 +221,8 @@ public async Task GrantConsentSetsCookie() 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 494/611] 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 6f2c5e2ec..8c4a63cad 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 @@ public Startup(IHostingEnvironment env) // 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 @@ public void Configure(IApplicationBuilder app) 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 495/611] 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 4e35c165f..fffb8cc88 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -579,7 +579,13 @@ public async Task CreateConsentCookieMatchesGrantConsentCookie() 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 @@ public async Task CreateConsentCookieAppliesPolicy() 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 496/611] 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 c7b6e3431..4eea96ab6 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 6c59666f3..64bdbb444 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 1aaf7a18a..bd1daf187 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 a474bc0e3..851bfbf20 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 bd5d51a51..678d8bb94 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 497/611] 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 bf30832e1..c5a4ece3c 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 7c2e97aa7..232cb858c 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 498/611] 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 5d0afba46..9a2fbfbc7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -240,6 +240,13 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper 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 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper 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 4f722323d..ce7494fb4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -155,6 +155,13 @@ protected virtual async Task HandleRemoteSignOutAsync() /// 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 ef4292100..4399ce5f7 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -118,8 +118,24 @@ protected virtual async Task InitializeEventsAsync() 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 @@ protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) 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 @@ public async Task ChallengeAsync(AuthenticationProperties properties) 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 18d4c9788..a547d203b 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 @@ public virtual void Validate(string scheme) /// 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 789f5ede9..b2726bac8 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.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 @@ public class CookieTests { 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 2314b6b3c..684482ed5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -5,11 +5,13 @@ 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 944a4827c..8bfbaacde 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -10,6 +10,7 @@ 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 @@ private static TestServer CreateServer(Action configureOptions, F .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 97adb2105..b472a4162 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.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 b2854e344..480241d35 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 65d865b94..9279f145b 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 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB "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 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv "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 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv 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 69ba75829..ed368c1ef 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 000000000..cd9fe9fb1 --- /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 2a63757b9..c1937d136 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -7,6 +7,7 @@ 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 499/611] 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 c5a4ece3c..b3ced8688 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 232cb858c..6f294ef0e 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 500/611] 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 b3ced8688..140d9ddbc 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 6f294ef0e..3e2b56b91 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 501/611] 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 140d9ddbc..7fcf154c2 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 502/611] 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 7fcf154c2..4edb3917c 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 3e2b56b91..89d0ad3d1 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 503/611] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5abab..65c8a07e3 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 504/611] 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 4edb3917c..ca0ede407 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 89d0ad3d1..e6c7fddff 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 505/611] #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 f598f34eb..3df759651 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 ca0ede407..4ccaf4fcb 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 000000000..40e1945c6 --- /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 000000000..bdf80e248 --- /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 000000000..0fc32769e --- /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 000000000..bc3a59f10 --- /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 000000000..f643fad97 --- /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 000000000..4028fa5e3 --- /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 000000000..654037d0a --- /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 000000000..8aec24a64 --- /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 000000000..311f41515 --- /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 000000000..1f32014b6 --- /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 000000000..55c3936f9 --- /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 000000000..e28b7e15b --- /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 000000000..4edb55cb3 --- /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 000000000..564e826a7 --- /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 000000000..e2edafb67 --- /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 000000000..3b97d995b --- /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 000000000..47091d58d --- /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 000000000..e47f8431f --- /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 000000000..4e0612677 --- /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 000000000..62647d4fc --- /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 57fed96c0..469726690 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 000000000..0de867d28 --- /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 000000000..dfdb0d68d --- /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 000000000..dfe860724 --- /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 000000000..05882518f --- /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 000000000..2addae96c --- /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 000000000..bc1ef757f --- /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 000000000..920ed66a4 --- /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 506/611] 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 6143a4f23..92d1d003e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -9,10 +9,10 @@ public static class FacebookDefaults 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 684482ed5..99177d66b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -585,7 +585,7 @@ public async Task NestedMapWillNotAffectRedirect() 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 @@ public async Task MapWillNotAffectRedirect() 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 @@ public async Task ChallengeWillTriggerRedirection() 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 507/611] 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 e4bd66615..042870318 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -12,7 +12,7 @@ public static class GoogleDefaults 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 8bfbaacde..c3e80ef71 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -457,7 +457,7 @@ public async Task ChallengeWillTriggerRedirection() 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 508/611] 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 12fc8ff28..3fc09a3db 100644 --- a/samples/CookiePolicySample/Program.cs +++ b/samples/CookiePolicySample/Program.cs @@ -12,7 +12,7 @@ public static void Main(string[] args) .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 b99fed2c3..1a810b7d5 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 @@ public CookiePolicyMiddleware( 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 000000000..21b04facc --- /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 1a42b04dd..40f97633a 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 e05cc9466..126c4d7bd 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -5,21 +5,23 @@ 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 @@ public bool IsConsentNeeded { _isConsentNeeded = Options.CheckConsentNeeded == null ? false : Options.CheckConsentNeeded(Context); + _logger.NeedsConsent(_isConsentNeeded.Value); } return _isConsentNeeded.Value; @@ -52,6 +55,7 @@ public bool HasConsent { 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 @@ public void GrantConsent() 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 @@ public void WithdrawConsent() 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 @@ public void Append(string key, string value, CookieOptions options) { 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 @@ public void Delete(string key, CookieOptions options) // 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 @@ public void Delete(string key, CookieOptions options) { 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 @@ private void ApplyPolicy(CookieOptions options) 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 @@ private void ApplyPolicy(CookieOptions options) 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 7c34f950a..a2592e557 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -102,7 +102,7 @@ await RunTest("/secureSame", 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 509/611] 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 9a2fbfbc7..5993f7532 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -31,6 +31,7 @@ public class CookieAuthenticationHandler : 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 @@ private void RequestRefresh(AuthenticationTicket ticket) _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 @@ protected virtual async Task FinishResponseAsync() 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 b2726bac8..945ec82ee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -515,8 +515,10 @@ public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri() 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 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() 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 @@ public async Task CookieIsRenewedWithSlidingExpiration() 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 @@ private class ClaimsTransformer : IClaimsTransformation { 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 @@ private TestServer CreateServer(Action configureOpt { 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 510/611] 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 9feff29d0..9215df975 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 511/611] 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 65c8a07e3..a11ea1ed5 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 512/611] 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 4ccaf4fcb..d0cb88aa8 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 e6c7fddff..138d848db 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 513/611] 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 3eefb7af7..143be1b9b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -9,7 +9,7 @@ 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 514/611] 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 5993f7532..343cf1b3a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,10 +14,7 @@ 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 @@ protected virtual async Task FinishResponseAsync() } } - 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 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper 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 000000000..7673fc1a0 --- /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 7bf8fe96e..401b1f488 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -91,15 +91,15 @@ public virtual AuthenticationBuilder AddRemoteScheme(string } /// - /// 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 4399ce5f7..5c9a6473f 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 000000000..4dbbb7de2 --- /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 000000000..1921c77ec --- /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 000000000..dbd612dc1 --- /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 000000000..015cb39e0 --- /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 4a023bec2..000000000 --- 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 38d819bf5..000000000 --- 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 a43478c94..368026beb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs @@ -12,26 +12,26 @@ 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 @@ public async Task CanDispatch() [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 @@ public async Task DefaultTargetSelectorWinsOverDefaultTarget() [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 @@ public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() [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 @@ public async Task SpecificTargetAlwaysWinsOverDefaultTarget() [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 @@ public async Task VirtualSchemeTargetsForwardWithDefaultTarget() [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 @@ public async Task CanDynamicTargetBasedOnQueryString() 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 @@ public async Task CanDynamicTargetBasedOnQueryString() 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 515/611] 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 d0cb88aa8..d0dfac301 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 541470c9f..2ab5a2ae3 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 9215df975..36045f12b 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 138d848db..e40ef6651 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 516/611] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed5..24f2b00a0 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 517/611] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51..678d8bb94 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 518/611] 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 469726690..6c8d518ff 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 509b85e64..6bb5445dc 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 @@ public TestSettings(Action configure) { configure?.Invoke(o); _options = o; + _options.BackchannelHttpHandler = new MockBackchannel(); }; } @@ -206,8 +212,6 @@ private void ValidateParameters( } } - OpenIdConnectOptions _options = null; - private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) { string expectedAuthority; @@ -305,5 +309,37 @@ private void ValidateParameter( 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 000000000..4d46a8cf0 --- /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 000000000..77cc5562a --- /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 519/611] 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 d0dfac301..d80ecef5a 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 e40ef6651..f531e7b0f 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 1f1115460..52fa29be9 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 82a48a6bf..2500e5fb5 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 61aae649d..edaade326 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 997cf7bdf..44fc928ca 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 5791297b2..966f7e1b1 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 ffda3cbaf..142e37c6b 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 9623b214e..a57e2eb87 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 b577f07eb..196b85372 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 000000000..5a8110fbc --- /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 6db7d2c81..a6082e8c4 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 0bad3ed62..a2a971f82 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 6108db6d2..9910c93f6 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 97da7ea5c..050546810 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 a55bf8f33..65256bed6 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 520/611] 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 c05bc8b52..82bfdf54f 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 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); + services.AddAuthentication(sharedOptions => { sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -56,9 +59,13 @@ public void ConfigureServices(IServiceCollection services) 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 f3fee6a22..5a178957a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs @@ -87,6 +87,27 @@ public static void MapCustomJson(this ClaimActionCollection collection, string c 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 @@ public static void DeleteClaim(this ClaimActionCollection collection, string cla { 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 000000000..b3bf5d99f --- /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 541e1edf2..b083e9d76 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs @@ -51,5 +51,62 @@ public void CanMapArrayValueUserDataToClaims() 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 521/611] 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 99177d66b..4ee9117f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -426,15 +426,15 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() { 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 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() { 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 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() { 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 @@ public async Task ThrowsIfAppIdMissing() 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 @@ public async Task ThrowsIfAppSecretMissing() 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 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }; }); }, - 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 @@ public async Task MapWillNotAffectRedirect() 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 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() { services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() - .AddFacebook(o => + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -728,7 +724,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() 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 @@ private static TestServer CreateServer(Action configure, Ac 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 c3e80ef71..d9af95936 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -551,28 +551,26 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() { 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 @@ public AuthenticationProperties Unprotect(string protectedText, string purpose) } } } -} +} \ 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 522/611] 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 | 45 +++-- .../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, 936 insertions(+), 42 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 82bfdf54f..1aa7625cb 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -225,11 +225,28 @@ await WriteHtmlAsync(response, async res => 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 0f83c1719..eb4251143 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 @@ private string GenerateAppSecretProof(string accessToken) } } - 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 000000000..714df4565 --- /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 091896f7c..88d48d446 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -57,12 +57,12 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties, 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 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties, return authorizationEndpoint; } - private static void AddQueryString( + private void AddQueryString( IDictionary queryStrings, AuthenticationProperties properties, string name, - string defaultValue = null) + Func formatter, + T defaultValue) { - string value; - if (!properties.Items.TryGetValue(name, out value)) + string value = null; + var parameterValue = properties.GetParameter(name); + if (parameterValue != null) { - value = defaultValue; + value = formatter(parameterValue); } - else + else if (!properties.Items.TryGetValue(name, out value)) { - // Remove the parameter from AuthenticationProperties so it won't be serialized to state parameter - properties.Items.Remove(name); + value = formatter(defaultValue); } - if (value == null) + // Remove the parameter from AuthenticationProperties so it won't be serialized into the state + properties.Items.Remove(name); + + if (value != null) { - return; + queryStrings[name] = value; } - - queryStrings[name] = value; } + + private void AddQueryString( + IDictionary queryStrings, + AuthenticationProperties properties, + string name, + string defaultValue = null) + => 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 000000000..fc768a8ac --- /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 80680a7cf..808e0f903 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -209,7 +209,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 @@ protected virtual string BuildChallengeUrl(AuthenticationProperties properties, 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 000000000..0ced488de --- /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 ce7494fb4..029cf541b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -329,15 +329,16 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop 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 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// 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 4ee9117f9..b909be9fd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -559,6 +559,97 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() 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 d9af95936..511a658ff 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -16,6 +16,7 @@ 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 @@ public async Task ChallengeWillSetDefaultScope() } [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 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() }); 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 @@ public AuthenticationProperties Unprotect(string protectedText, string purpose) } } } -} \ 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 480241d35..e2e13f270 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -525,6 +525,57 @@ public async Task ChallengeWillTriggerRedirection() 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 @@ private static TestServer CreateServer(Action configure { 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 000000000..c359bb0e8 --- /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 9279f145b..4b822b611 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -572,6 +572,88 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv 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 7ab81c9dd..cbafc4622 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -51,14 +51,14 @@ public async Task ChallengeRedirectIsIssuedCorrectly() [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 @@ public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); settings.ValidateChallengeRedirect( res.Headers.Location, OpenIdConnectParameterNames.MaxAge); @@ -446,9 +447,170 @@ public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() 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 6bb5445dc..a1e0233f3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -206,6 +206,9 @@ private void ValidateParameters( 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 @@ private void ValidateMaxAge(IDictionary actualQuery, ICollection } } + 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 523/611] Update dependencies --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d80ecef5a..90c4b7414 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 524/611] 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 d0cb88aa8..23bd79dbc 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 138d848db..3a326c7d5 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 525/611] 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 90c4b7414..303f56bca 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 f531e7b0f..b8e036fe2 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 526/611] 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 23bd79dbc..fabe53792 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 3a326c7d5..b3af0b8bc 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 527/611] 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 fabe53792..9f302ba91 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 b3af0b8bc..b419d767b 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 528/611] 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 541470c9f..a4f86fb2f 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 bd5d51a51..678d8bb94 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 24f2b00a0..e27532787 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 6e0377bad8c44e1394234500bfddb90e87fcaed6 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:02:18 -0700 Subject: [PATCH 529/611] Update version number to 2.2.0 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index 24f2b00a0..44985cedb 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.1.0 - preview3 + 2.2.0 + preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 2e3a1071a884de19d33daa00bbdc2b7614d73646 Mon Sep 17 00:00:00 2001 From: Devin Garner Date: Tue, 17 Apr 2018 10:34:10 -0600 Subject: [PATCH 530/611] Correct Twitter OAuth signing code & refactor copy/pasted code. #1695 (#1720) --- .../TwitterHandler.cs | 182 ++++++------------ 1 file changed, 63 insertions(+), 119 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 670e76f7e..d0d54bf74 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -148,53 +148,92 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop await Events.RedirectToAuthorizationEndpoint(redirectContext); } - private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) + private async Task ExecuteRequestAsync(string url, HttpMethod httpMethod, RequestToken accessToken = null, Dictionary extraOAuthPairs = null, Dictionary queryParameters = null, Dictionary formData = null) { - Logger.ObtainRequestToken(); - - var nonce = Guid.NewGuid().ToString("N"); - - var authorizationParts = new SortedDictionary + var authorizationParts = new SortedDictionary(extraOAuthPairs ?? new Dictionary()) { - { "oauth_callback", callBackUri }, { "oauth_consumer_key", Options.ConsumerKey }, - { "oauth_nonce", nonce }, + { "oauth_nonce", Guid.NewGuid().ToString("N") }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", GenerateTimeStamp() }, { "oauth_version", "1.0" } }; + if (accessToken != null) + { + authorizationParts.Add("oauth_token", accessToken.Token); + } + + var signatureParts = new SortedDictionary(authorizationParts); + if (queryParameters != null) + { + foreach (var queryParameter in queryParameters) + { + signatureParts.Add(queryParameter.Key, queryParameter.Value); + } + } + if (formData != null) + { + foreach (var formItem in formData) + { + signatureParts.Add(formItem.Key, formItem.Value); + } + } + var parameterBuilder = new StringBuilder(); - foreach (var authorizationKey in authorizationParts) + foreach (var signaturePart in signatureParts) { - parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value)); + parameterBuilder.AppendFormat("{0}={1}&", Uri.EscapeDataString(signaturePart.Key), Uri.EscapeDataString(signaturePart.Value)); } parameterBuilder.Length--; var parameterString = parameterBuilder.ToString(); var canonicalizedRequestBuilder = new StringBuilder(); - canonicalizedRequestBuilder.Append(HttpMethod.Post.Method); + canonicalizedRequestBuilder.Append(httpMethod.Method); canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(RequestTokenEndpoint)); + canonicalizedRequestBuilder.Append(Uri.EscapeDataString(url)); canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); + canonicalizedRequestBuilder.Append(Uri.EscapeDataString(parameterString)); - var signature = ComputeSignature(Options.ConsumerSecret, null, canonicalizedRequestBuilder.ToString()); + var signature = ComputeSignature(Options.ConsumerSecret, accessToken?.TokenSecret, canonicalizedRequestBuilder.ToString()); authorizationParts.Add("oauth_signature", signature); + var queryString = ""; + if (queryParameters != null) + { + var queryStringBuilder = new StringBuilder("?"); + foreach (var queryParam in queryParameters) + { + queryStringBuilder.AppendFormat("{0}={1}&", queryParam.Key, queryParam.Value); + } + queryStringBuilder.Length--; + queryString = queryStringBuilder.ToString(); + } + var authorizationHeaderBuilder = new StringBuilder(); authorizationHeaderBuilder.Append("OAuth "); foreach (var authorizationPart in authorizationParts) { - authorizationHeaderBuilder.AppendFormat( - "{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value)); + authorizationHeaderBuilder.AppendFormat("{0}=\"{1}\",", authorizationPart.Key, Uri.EscapeDataString(authorizationPart.Value)); } - authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2; + authorizationHeaderBuilder.Length--; - var request = new HttpRequestMessage(HttpMethod.Post, RequestTokenEndpoint); + var request = new HttpRequestMessage(httpMethod, url + queryString); request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - var response = await Backchannel.SendAsync(request, Context.RequestAborted); + if (formData != null) + { + request.Content = new FormUrlEncodedContent(formData); + } + + return await Backchannel.SendAsync(request, Context.RequestAborted); + } + + private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) + { + Logger.ObtainRequestToken(); + + var response = await ExecuteRequestAsync(RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); @@ -213,58 +252,8 @@ private async Task ObtainAccessTokenAsync(RequestToken token, strin Logger.ObtainAccessToken(); - var nonce = Guid.NewGuid().ToString("N"); - - var authorizationParts = new SortedDictionary - { - { "oauth_consumer_key", Options.ConsumerKey }, - { "oauth_nonce", nonce }, - { "oauth_signature_method", "HMAC-SHA1" }, - { "oauth_token", token.Token }, - { "oauth_timestamp", GenerateTimeStamp() }, - { "oauth_verifier", verifier }, - { "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 canonicalizedRequestBuilder = new StringBuilder(); - canonicalizedRequestBuilder.Append(HttpMethod.Post.Method); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(AccessTokenEndpoint)); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); - - var signature = ComputeSignature(Options.ConsumerSecret, token.TokenSecret, canonicalizedRequestBuilder.ToString()); - authorizationParts.Add("oauth_signature", signature); - authorizationParts.Remove("oauth_verifier"); - - 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.Post, AccessTokenEndpoint); - request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - - var formPairs = new Dictionary() - { - { "oauth_verifier", verifier }, - }; - - request.Content = new FormUrlEncodedContent(formPairs); - - var response = await Backchannel.SendAsync(request, Context.RequestAborted); + var formPost = new Dictionary { { "oauth_verifier", verifier } }; + var response = await ExecuteRequestAsync(AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); if (!response.IsSuccessStatusCode) { @@ -289,53 +278,8 @@ private async Task RetrieveUserDetailsAsync(AccessToken accessToken, Cl { 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 ExecuteRequestAsync("https://api.twitter.com/1.1/account/verify_credentials.json", HttpMethod.Get, accessToken, queryParameters: new Dictionary() { { "include_email", "true" } }); - var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { Logger.LogError("Email request failed with a status code of " + response.StatusCode); @@ -361,8 +305,8 @@ private string ComputeSignature(string consumerSecret, string tokenSecret, strin algorithm.Key = Encoding.ASCII.GetBytes( string.Format(CultureInfo.InvariantCulture, "{0}&{1}", - UrlEncoder.Encode(consumerSecret), - string.IsNullOrEmpty(tokenSecret) ? string.Empty : UrlEncoder.Encode(tokenSecret))); + Uri.EscapeDataString(consumerSecret), + string.IsNullOrEmpty(tokenSecret) ? string.Empty : Uri.EscapeDataString(tokenSecret))); var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(signatureData)); return Convert.ToBase64String(hash); } From 5e8f54a55fcf77fe20f1ca8c466b4cc60f366352 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:44:34 -0700 Subject: [PATCH 531/611] 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 894b1d0cf..53b3f6e1d 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 9f302ba91..4dc778d54 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 532/611] 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 4dc778d54..2cb9387b7 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 b419d767b..9d4ef8c88 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 db19d87bfa41fa5a11a318d12f8f1f1e0e27c3df Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 23 Apr 2018 12:25:11 -0700 Subject: [PATCH 533/611] 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 2cb9387b7..6a1705582 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(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.2.0-preview1-17037 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1-26419-02 + 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 b419d767b..f27a67b44 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.2.0-preview1-17037 +commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e From 02ddceac287052775c4205738d5a61838420da6e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Apr 2018 12:31:25 -0700 Subject: [PATCH 534/611] 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 6a1705582..b28166798 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17037 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 + 2.2.0-preview1-17042 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26413-05 + 2.2.0-preview1-26424-04 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 f27a67b44..335e579e0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17037 -commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e +version:2.2.0-preview1-17042 +commithash:edf0705d014293c260de763543784330514db9a3 From 3cc514c875512c1426f7ae07d4a8e36ffcbbfb30 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:45 -0700 Subject: [PATCH 535/611] 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 e27532787..b9552451d 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From a2cb92b358daf7552294060cd947d85afcc07049 Mon Sep 17 00:00:00 2001 From: Alexey Malinin Date: Tue, 1 May 2018 23:22:27 +0700 Subject: [PATCH 536/611] Code improvements of JwtBearer module (#1742) * Use pattern matching to check exception type in JwtBearerHandler * Use expression body to configure events in JwtBearerHandler --- .../JwtBearerHandler.cs | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 6d5c7f5f5..452d9639f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -32,8 +32,8 @@ public JwtBearerHandler(IOptionsMonitor options, ILoggerFactor /// protected new JwtBearerEvents Events { - get { return (JwtBearerEvents)base.Events; } - set { base.Events = value; } + get => (JwtBearerEvents)base.Events; + set => base.Events = value; } protected override Task CreateEventsAsync() => Task.FromResult(new JwtBearerEvents()); @@ -267,9 +267,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop private static string CreateErrorDescription(Exception authFailure) { IEnumerable exceptions; - if (authFailure is AggregateException) + if (authFailure is AggregateException agEx) { - var agEx = authFailure as AggregateException; exceptions = agEx.InnerExceptions; } else @@ -283,37 +282,32 @@ private static string CreateErrorDescription(Exception authFailure) { // Order sensitive, some of these exceptions derive from others // and we want to display the most specific message possible. - if (ex is SecurityTokenInvalidAudienceException) + switch (ex) { - 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"); + case SecurityTokenInvalidAudienceException _: + messages.Add("The audience is invalid"); + break; + case SecurityTokenInvalidIssuerException _: + messages.Add("The issuer is invalid"); + break; + case SecurityTokenNoExpirationException _: + messages.Add("The token has no expiration"); + break; + case SecurityTokenInvalidLifetimeException _: + messages.Add("The token lifetime is invalid"); + break; + case SecurityTokenNotYetValidException _: + messages.Add("The token is not valid yet"); + break; + case SecurityTokenExpiredException _: + messages.Add("The token is expired"); + break; + case SecurityTokenSignatureKeyNotFoundException _: + messages.Add("The signature key was not found"); + break; + case SecurityTokenInvalidSignatureException _: + messages.Add("The signature is invalid"); + break; } } From 4dbcfa5e508221b3d71a2ff7d66979282dacee33 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:50:04 -0700 Subject: [PATCH 537/611] 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 2cb9387b7..d55f378cc 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 9d4ef8c88..3673744db 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 8bd15fcec12ea1f4209da8fdb8f2f4bcc41547b4 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 6 May 2018 12:30:25 -0700 Subject: [PATCH 538/611] 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 b28166798..6f1ddb34d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17042 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 + 2.2.0-preview1-17047 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 335e579e0..a16d4b9ee 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17042 -commithash:edf0705d014293c260de763543784330514db9a3 +version:2.2.0-preview1-17047 +commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c From a10c3cb23b0a2e13a8a88e2cccc19e76e8b696ed Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 7 May 2018 15:15:40 -0700 Subject: [PATCH 539/611] Upgrade to netcoreapp22 --- Directory.Build.targets | 5 +- build/dependencies.props | 57 ++++++++++--------- build/repo.props | 3 +- korebuild-lock.txt | 4 +- .../CookiePolicySample.csproj | 4 +- samples/CookieSample/CookieSample.csproj | 4 +- .../CookieSessionSample.csproj | 4 +- .../JwtBearerSample/JwtBearerSample.csproj | 4 +- .../OpenIdConnect.AzureAdSample.csproj | 4 +- .../OpenIdConnectSample.csproj | 4 +- samples/SocialSample/SocialSample.csproj | 4 +- samples/WsFedSample/WsFedSample.csproj | 2 +- test/Directory.Build.props | 6 +- .../OpenIdConnect/TestSettings.cs | 2 +- 14 files changed, 56 insertions(+), 51 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 53b3f6e1d..78626b773 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,10 @@ - + $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) + + 99.9 diff --git a/build/dependencies.props b/build/dependencies.props index 6f1ddb34d..79f94d403 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,40 +1,41 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17047 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 + 2.2.0-preview1-17048 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 3.14.2 5.2.0 5.2.0 2.0.0 2.2.0-preview1-26424-04 + 2.2.0-preview1-26502-01 15.6.1 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f..6fc6af601 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -13,5 +13,6 @@ + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a16d4b9ee..2573a0399 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17047 -commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c +version:2.2.0-preview1-17048 +commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj index fb2e7d917..48227eb07 100644 --- a/samples/CookiePolicySample/CookiePolicySample.csproj +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 193137b86..1029f1819 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 6241edd66..19bd04374 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 84b436581..3e0192a23 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index b14b9590f..2abd57cd8 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 23e87d4f2..bb02ef159 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a423ae21a..a08b9799d 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-SocialSample-20151210111056 diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj index bc3a59f10..4fb38fa3e 100644 --- a/samples/WsFedSample/WsFedSample.csproj +++ b/samples/WsFedSample/WsFedSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.0 + net461 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index b842a4831..e3d2d9f14 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,10 +1,10 @@ - + - netcoreapp2.1 + netcoreapp2.2 $(DeveloperBuildTestTfms) - $(StandardTestTfms);netcoreapp2.0 + $(StandardTestTfms) $(StandardTestTfms);net461 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index a1e0233f3..b32e0723f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -259,7 +259,7 @@ private void ValidateState(IDictionary actualParams, ICollection ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_0 || NETCOREAPP2_1 +#if NETCOREAPP2_2 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); #elif NET461 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); From 23b2b00e0ecd4d6c57698156d7679aa4caea7838 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 13 May 2018 14:22:46 -0700 Subject: [PATCH 540/611] 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 79f94d403..5c678ea41 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,41 +1,41 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17048 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 + 2.2.0-preview1-17051 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 3.14.2 5.2.0 5.2.0 2.0.0 - 2.2.0-preview1-26424-04 - 2.2.0-preview1-26502-01 + 2.1.0-rc1 + 2.2.0-preview1-26509-06 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2573a0399..89629b454 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17048 -commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 +version:2.2.0-preview1-17051 +commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b From 1aa78a585324d80bf99bf83e7c28fbd9038fc610 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 16 May 2018 15:41:01 -0700 Subject: [PATCH 541/611] 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 b472a4162..20d625d31 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 @@ public async Task VerifySchemeDefaults() 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 fb80636cb53cb5d29c810a28fb15e2690677cb4e Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Fri, 18 May 2018 14:56:14 -1000 Subject: [PATCH 542/611] Cookie Policy sample essential cookie (#1762) --- samples/CookiePolicySample/Startup.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/CookiePolicySample/Startup.cs b/samples/CookiePolicySample/Startup.cs index 7ce9c2d2d..4dcc6d4dc 100644 --- a/samples/CookiePolicySample/Startup.cs +++ b/samples/CookiePolicySample/Startup.cs @@ -58,6 +58,13 @@ private void NestedApp(IApplicationBuilder app) case "/RemoveTempCookie": context.Response.Cookies.Delete("Temp"); break; + case "/CreateEssentialCookie": + context.Response.Cookies.Append("EssentialCookie", "2", + new CookieOptions() { IsEssential = true }); + break; + case "/RemoveEssentialCookie": + context.Response.Cookies.Delete("EssentialCookie"); + break; case "/GrantConsent": context.Features.Get().GrantConsent(); break; @@ -84,6 +91,8 @@ private async Task HomePage(HttpContext context) 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($"Create Essential Cookie
\r\n"); + await response.WriteAsync($"Remove Essential Cookie
\r\n"); await response.WriteAsync($"Grant Consent
\r\n"); await response.WriteAsync($"Withdraw Consent
\r\n"); await response.WriteAsync("
\r\n"); From e031eff146c8aad43e63cd8d32e8fe382a0c8d66 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 20 May 2018 19:46:07 +0000 Subject: [PATCH 543/611] 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 5c678ea41..b839b4984 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- 2.2.0-preview1-17051 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 + 2.2.0-preview1-17060 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89629b454..cf2fff7de 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17051 -commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b +version:2.2.0-preview1-17060 +commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b From 0f18ff1b9fecd99abc7682f93f182d874e95ea07 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Wed, 23 May 2018 10:25:19 -0500 Subject: [PATCH 544/611] 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 3f6c2d917..da9b6ea01 100644 --- a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -33,7 +33,7 @@ public class HandleRequestResult : AuthenticateResult { throw new ArgumentNullException(nameof(ticket)); } - return new HandleRequestResult() { Ticket = ticket }; + return new HandleRequestResult() { Ticket = ticket, Properties = ticket.Properties }; } /// From 9ee5ed4bf908bf09fce2d4d4797a908cc927b72c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 23 May 2018 15:35:23 -0700 Subject: [PATCH 545/611] 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 b9552451d..669c87482 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 20a4aa0bb093b8617b1a30dab1ded2eda460d3e0 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Fri, 25 May 2018 16:17:12 -0700 Subject: [PATCH 546/611] Update bootstrapper scripts (automated commit) [ci skip] --- run.ps1 | 25 +++++++++++++++++++------ run.sh | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/run.ps1 b/run.ps1 index 27dcf848f..3b2738246 100644 --- a/run.ps1 +++ b/run.ps1 @@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c .PARAMETER Update Updates KoreBuild to the latest version even if a lock file is present. +.PARAMETER Reinstall +Re-installs KoreBuild + .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 CI +Sets up CI specific settings and variables. + .PARAMETER Arguments Arguments to be passed to the command @@ -65,8 +71,10 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile, + [switch]$Reinstall, [string]$ToolsSourceSuffix, + [string]$ConfigFile = $null, + [switch]$CI, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -93,6 +101,10 @@ function Get-KoreBuild { $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if ($Reinstall -and (Test-Path $korebuildPath)) { + Remove-Item -Force -Recurse $korebuildPath + } + if (!(Test-Path $korebuildPath)) { Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" New-Item -ItemType Directory -Path $korebuildPath | Out-Null @@ -101,9 +113,9 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath + Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } else { # Fallback to old approach for old installations of PowerShell @@ -167,8 +179,9 @@ if (Test-Path $ConfigFile) { } } catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] + Write-Host -ForegroundColor Red $Error[0] + Write-Error "$ConfigFile contains invalid JSON." + exit 1 } } @@ -188,7 +201,7 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI Invoke-KoreBuildCommand $Command @Arguments } finally { diff --git a/run.sh b/run.sh index 834961fc3..02aac1587 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" verbose=false update=false +reinstall=false repo_path="$DIR" channel='' tools_source='' tools_source_suffix='' +ci=false # # Functions @@ -38,6 +40,8 @@ __usage() { 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 " --reinstall Reinstall KoreBuild." + echo " --ci Apply CI specific settings and environment variables." 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." @@ -62,6 +66,10 @@ get_korebuild() { version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then + rm -rf "$korebuild_path" + fi + { if [ ! -d "$korebuild_path" ]; then mkdir -p "$korebuild_path" @@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do -u|--update|-Update) update=true ;; + --reinstall|-[Rr]einstall) + reinstall=true + ;; + --ci|-[Cc][Ii]) + ci=true + ;; --verbose|-Verbose) verbose=true ;; @@ -206,17 +220,28 @@ if [ -f "$config_file" ]; 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." + _error "$config_file contains invalid JSON." + exit 1 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." + _error "$config_file contains invalid JSON." + exit 1 + fi + elif __machine_has python3 ; then + if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python3 -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="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + _error "$config_file contains invalid JSON." + exit 1 fi else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + _error 'Missing required command: jq or python. Could not parse the JSON file.' + exit 1 fi [ ! -z "${config_channel:-}" ] && channel="$config_channel" @@ -227,5 +252,5 @@ fi [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" invoke_korebuild_command "$command" "$@" From 12e9585faf69e1ea9eee5f09a8620ccfe4666091 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 27 May 2018 19:28:55 +0000 Subject: [PATCH 547/611] 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 b839b4984..af20bdc47 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17060 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 + 2.2.0-preview1-17064 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0-rc1 - 2.2.0-preview1-26509-06 + 2.2.0-preview1-26526-03 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cf2fff7de..3028b6676 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17060 -commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b +version:2.2.0-preview1-17064 +commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 From e538375c443a11d96370eb767fce7bb559e00dc9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:52:21 -0700 Subject: [PATCH 548/611] 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 d55f378cc..7d3788a5b 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 3673744db..cd5b409a1 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 0d4438d4c9bbcacf985452f5c27066dff52cb4a0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 3 Jun 2018 19:28:12 +0000 Subject: [PATCH 549/611] 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 af20bdc47..c31e4c85e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17064 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 + 2.2.0-preview1-17067 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1 - 2.2.0-preview1-26526-03 + 2.1.0 + 2.2.0-preview1-26531-03 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3028b6676..06ba6285b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17064 -commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 +version:2.2.0-preview1-17067 +commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f From 569eef4f7d255cbf23eb36cde69df01c0ce47105 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 5 Jun 2018 22:35:03 -0700 Subject: [PATCH 550/611] Add certificate names for code signing --- Directory.Build.props | 2 ++ korebuild-lock.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index adbda10ef..91cd995d7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,8 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true + Microsoft + MicrosoftNuGet true true diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 06ba6285b..b679b8042 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17067 -commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f +version:2.2.0-preview1-17075 +commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f From 38004ce37a6f006df950c9dcd7a566e5e1bcb631 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 7 Jun 2018 19:47:27 +0000 Subject: [PATCH 551/611] 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 c31e4c85e..81399c5d7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17067 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 + 2.2.0-preview1-17081 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0 - 2.2.0-preview1-26531-03 + 2.2.0-preview1-26606-01 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b679b8042..deb7e546f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17075 -commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f +version:2.2.0-preview1-17081 +commithash:73f09c256e2a54270951562ecc0ef4a953926c36 From cabaaef2ab834b61548a701858f5b0e83f94bead Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 7 Jun 2018 15:48:06 -0700 Subject: [PATCH 552/611] Adding VSTS file --- .vsts-pipelines/builds/ci-internal.yml | 13 +++++++++++++ .vsts-pipelines/builds/ci-public.yml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .vsts-pipelines/builds/ci-internal.yml create mode 100644 .vsts-pipelines/builds/ci-public.yml diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml new file mode 100644 index 000000000..d7ceb7637 --- /dev/null +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -0,0 +1,13 @@ +trigger: +- dev +- release/* + +resources: + repositories: + - repository: buildtools + type: git + name: aspnet-BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml new file mode 100644 index 000000000..b7f25723f --- /dev/null +++ b/.vsts-pipelines/builds/ci-public.yml @@ -0,0 +1,15 @@ +trigger: +- dev +- release/* + +# See https://github.com/aspnet/BuildTools +resources: + repositories: + - repository: buildtools + type: github + endpoint: DotNet-Bot GitHub Connection + name: aspnet/BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools From ac1a9ef6d183a94646a4b5e57b7be1c6e53b5605 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:33:42 +0000 Subject: [PATCH 553/611] 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 7d3788a5b..6fd8fd099 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 cd5b409a1..bc84e0cd5 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 b8a488bf9e44e0f03c6c072756568b19859dc225 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 14 Jun 2018 10:30:43 -0700 Subject: [PATCH 554/611] 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 | 714 ++++++++++++++++-- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 138 +++- .../baseline.netframework.json | 2 +- 14 files changed, 1831 insertions(+), 130 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 52fa29be9..b218669b7 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 7673fc1a0..000000000 --- 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 2500e5fb5..5d95efca6 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 edaade326..0a623b3b8 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 44fc928ca..d3839022b 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 966f7e1b1..877e9035a 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 142e37c6b..9c2394704 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 a57e2eb87..d5c10d18d 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 196b85372..03ee64562 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 5a8110fbc..41150cbc0 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 a6082e8c4..08eeb5e7b 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", @@ -1966,59 +2184,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_UtcNow", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.DateTimeOffset", + "ReturnType": "System.Boolean", + "Visibility": "Public", "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", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Protected", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "Fail", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "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", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "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", + "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": [] }, { @@ -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" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "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" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "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": "Handle", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "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": "SkipHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "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": [], + "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.SystemClock", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index a2a971f82..e8708538d 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 050546810..01a16c57a 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 65256bed6..bfc0c0076 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 aa24887d4371660fdf1e2100a0c1d9957d42fb63 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 14 Jun 2018 10:30:43 -0700 Subject: [PATCH 555/611] 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 | 714 ++++++++++++++++-- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 138 +++- .../baseline.netframework.json | 2 +- 14 files changed, 1831 insertions(+), 130 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 52fa29be9..b218669b7 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 7673fc1a0..000000000 --- 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 2500e5fb5..5d95efca6 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 edaade326..0a623b3b8 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 44fc928ca..d3839022b 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 966f7e1b1..877e9035a 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 142e37c6b..9c2394704 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 a57e2eb87..d5c10d18d 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 196b85372..03ee64562 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 5a8110fbc..41150cbc0 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 a6082e8c4..08eeb5e7b 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", @@ -1966,59 +2184,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_UtcNow", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.DateTimeOffset", + "ReturnType": "System.Boolean", + "Visibility": "Public", "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", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Protected", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "Fail", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "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", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "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", + "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": [] }, { @@ -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" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "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" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "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": "Handle", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "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": "SkipHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "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": [], + "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.SystemClock", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index a2a971f82..e8708538d 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 050546810..01a16c57a 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 65256bed6..bfc0c0076 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 d8821d7eb120744f5439bcf85ad39c72537e85d3 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 25 Jun 2018 11:29:05 -0700 Subject: [PATCH 556/611] 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 81399c5d7..db9d0bec1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17081 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 + 2.2.0-preview1-17090 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0 - 2.2.0-preview1-26606-01 + 2.2.0-preview1-26618-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index deb7e546f..a8109db52 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17081 -commithash:73f09c256e2a54270951562ecc0ef4a953926c36 +version:2.2.0-preview1-17090 +commithash:b19e903e946579cd9482089bce7d917e8bacd765 From 26fbad061475e4cf8d27d0e364048a924ead953b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 27 Jun 2018 13:39:51 -0700 Subject: [PATCH 557/611] 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 669c87482..478dfd16e 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 866b0b66a4f06fd7aba74f12f20e14f4f153e30b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:21:46 -0700 Subject: [PATCH 558/611] Update infrastructure for the 2.2 release --- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- build/repo.props | 1 + korebuild.json | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb7637..dc7b8a3cb 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/release/2.2 phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f..f5087d9c3 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/release/2.2 + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/build/repo.props b/build/repo.props index 6fc6af601..077c753e6 100644 --- a/build/repo.props +++ b/build/repo.props @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51..d217d06e3 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.2/tools/korebuild.schema.json", + "channel": "release/2.2" } From 7229c6086603d424ce14a3870d654228128ac6c6 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:48:58 -0700 Subject: [PATCH 559/611] Bumping version from 2.2.0 to 3.0.0 --- version.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.props b/version.props index 44985cedb..71a78cddd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - + - 2.2.0 - preview1 + 3.0.0 + alpha1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 238f461488746608108d2358a2a3ad3a1117ee9f Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 2 Jul 2018 12:40:35 -0700 Subject: [PATCH 560/611] [automated] Change default branch to master --- .appveyor.yml | 2 +- .travis.yml | 2 +- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- korebuild.json | 4 ++-- run.ps1 | 6 +++--- run.sh | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4eea96ab6..d45bd5a1f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ init: - git config --global core.autocrlf true branches: only: - - dev + - master - /^release\/.*$/ - /^(.*\/)?ci-.*$/ build_script: diff --git a/.travis.yml b/.travis.yml index 64bdbb444..ab3980055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: - libunwind8 branches: only: - - dev + - master - /^release\/.*$/ - /^(.*\/)?ci-.*$/ before_install: diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb7637..c2c5336fd 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/master phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f..507c89b02 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/master + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/korebuild.json b/korebuild.json index bd5d51a51..8a276a7f3 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/master/tools/korebuild.schema.json", + "channel": "master" } diff --git a/run.ps1 b/run.ps1 index 3b2738246..34604c717 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac1587..61f7a5338 100755 --- a/run.sh +++ b/run.sh @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From d0d72782745edc41c79c501ff2210058a4eadb46 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Jul 2018 16:27:20 +0000 Subject: [PATCH 561/611] 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 db9d0bec1..5b20d12ff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 + 3.0.0-alpha1-10000 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a8109db52..f0b76184f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:3.0.0-alpha1-10000 +commithash:b7b88d08d55abc8b71de9abf16e26fc713e332cd From 8b30c7359769cd9e3360c065d610598aa99da0c6 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 12:28:09 -0700 Subject: [PATCH 562/611] 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 db9d0bec1..7186de797 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 + 2.2.0-preview1-17099 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 3.14.2 5.2.0 5.2.0 - 2.0.0 - 2.1.0 + 2.0.7 + 2.1.1 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -45,7 +45,7 @@ 5.2.0 0.8.0 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a8109db52..27e2e80f9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:2.2.0-preview1-17099 +commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 From 36276e737842267ebb88a2cacb7c6223e117da6d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 20:09:29 +0000 Subject: [PATCH 563/611] 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 5b20d12ff..f013f62a6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10000 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 + 3.0.0-alpha1-10005 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 3.14.2 5.2.0 5.2.0 @@ -45,7 +45,7 @@ 5.2.0 0.8.0 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f0b76184f..f357ac9f7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10000 -commithash:b7b88d08d55abc8b71de9abf16e26fc713e332cd +version:3.0.0-alpha1-10005 +commithash:05570853de976a526462ca140a55b1ac59d9a351 From d2a8d3a61c4f393170be4f6e49b287d0f3a4d96d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 11 Jul 2018 13:14:51 -0700 Subject: [PATCH 564/611] 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 343cf1b3a..b77a51ef4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -85,7 +85,7 @@ private void CheckForRefresh(AuthenticationTicket ticket) } } - 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 @@ private void RequestRefresh(AuthenticationTicket ticket) _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 @@ protected override async Task HandleAuthenticateAsync() 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 945ec82ee..766d1e2e5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -900,6 +900,80 @@ public async Task CookieCanBeRenewedByValidator() 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 @@ private static string FindClaimValue(Transaction transaction, string claimType) 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 565/611] 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 3f6c2d917..da9b6ea01 100644 --- a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -33,7 +33,7 @@ public class HandleRequestResult : AuthenticateResult { 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 566/611] 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 b472a4162..20d625d31 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 @@ public async Task VerifySchemeDefaults() 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 567/611] 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 20d625d31..d7fcdb4ca 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -468,6 +468,43 @@ public async Task BearerTokenValidation() 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 @@ private static TestServer CreateServer(Action options = null, 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 568/611] 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 6fd8fd099..5e6f87963 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 bc84e0cd5..251c227c8 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 569/611] 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 5e6f87963..828f9c7ab 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 320dd47694d4b7bc7f11737c5e9b7034713ca58f Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 12:27:24 -0700 Subject: [PATCH 570/611] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7186de797..a7c9e6a3e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,37 +4,37 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 3.14.2 5.2.0 5.2.0 - 2.0.7 - 2.1.1 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -43,7 +43,7 @@ 2.0.3 11.0.2 5.2.0 - 0.8.0 + 0.9.0 2.3.1 2.4.0-rc.1.build4038 From f948c0020b501defbb6b0015b437562f114a74f9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 20:11:51 +0000 Subject: [PATCH 571/611] 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 f013f62a6..d4a38538f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10005 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 + 3.0.0-alpha1-10009 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 3.14.2 5.2.0 5.2.0 - 2.0.0 - 2.1.0 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -43,7 +43,7 @@ 2.0.3 11.0.2 5.2.0 - 0.8.0 + 0.9.0 2.3.1 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f357ac9f7..4db537685 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10005 -commithash:05570853de976a526462ca140a55b1ac59d9a351 +version:3.0.0-alpha1-10009 +commithash:86be4707e47d2f1930a982f2b59eacfc4196da33 From f31166cbbcb24c34deba11da3b1aa1fae82d1d59 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 12:26:31 -0700 Subject: [PATCH 572/611] 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 a7c9e6a3e..f97a52471 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 3.14.2 5.2.0 5.2.0 From 48b8fc7c02ada57c9d6293142b9ada4ac07ad8be Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 13:14:06 -0700 Subject: [PATCH 573/611] 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 d4a38538f..efaeec400 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10009 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 + 3.0.0-alpha1-10011 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 4db537685..9a67ee9c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10009 -commithash:86be4707e47d2f1930a982f2b59eacfc4196da33 +version:3.0.0-alpha1-10011 +commithash:717c2eb1f91dafd2580c1a9b8e5064d12dd8c054 From 3b554fd9b2dc078ed0c47e62f8b93a3c3d2d314c Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 24 Jul 2018 10:57:22 -0700 Subject: [PATCH 574/611] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64ff041d5..eac4268e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ 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. +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. From 899a3a2e88d14124fe4155aaeab7c174197c1655 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 26 Jul 2018 14:50:52 -0700 Subject: [PATCH 575/611] Refactor common tests --- .../CookieTests.cs | 426 +-------------- .../FacebookTests.cs | 487 +---------------- .../GoogleTests.cs | 443 +-------------- .../JwtBearerTests.cs | 422 +-------------- .../MicrosoftAccountTests.cs | 443 +-------------- .../OAuthTests.cs | 439 +-------------- .../RemoteAuthenticationTests.cs | 92 ++++ .../SharedAuthenticationTests.cs | 510 ++++++++++++++++++ .../TwitterTests.cs | 437 +-------------- 9 files changed, 714 insertions(+), 2985 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 766d1e2e5..107fc5db1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -10,7 +10,6 @@ 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; @@ -22,431 +21,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieTests + public class CookieTests : SharedAuthenticationTests { 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); + protected override string DefaultScheme => CookieAuthenticationDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(CookieAuthenticationHandler); - 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() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - 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() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddCookie(); - 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); + services.AddCookie(configure); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b909be9fd..6802c60e7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -1,17 +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.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; @@ -20,476 +11,38 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.Facebook { - public class FacebookTests + public class FacebookTests : RemoteAuthenticationTests { - private void ConfigureDefaults(FacebookOptions o) - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - o.SignInScheme = "auth1"; - } + protected override string DefaultScheme => FacebookDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(FacebookHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - [Fact] - public async Task CanForwardDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddFacebook(o => + services.AddFacebook(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; + configure.Invoke(o); }); - - 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() + + protected override void ConfigureDefaults(FacebookOptions o) { - 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() - { - var server = CreateServer( - app => { }, - services => services.AddAuthentication().AddFacebook(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - o.SignInScheme = FacebookDefaults.AuthenticationScheme; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - 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(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - 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(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - 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() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddFacebook(); - 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); + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 511a658ff..19d7d898b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -1,16 +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.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.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -20,431 +10,40 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; +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 Xunit; namespace Microsoft.AspNetCore.Authentication.Google { - public class GoogleTests + public class GoogleTests : RemoteAuthenticationTests { - 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()); - } + protected override string DefaultScheme => GoogleDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(GoogleHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - [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() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddGoogle(o => + services.AddGoogle(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; + configure.Invoke(o); }); - - 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() + protected override void ConfigureDefaults(GoogleOptions o) { - 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() - { - 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() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddGoogle(); - 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); + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index d7fcdb4ca..ad77803cd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -1,6 +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.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; using System; using System.IdentityModel.Tokens.Jwt; using System.Linq; @@ -11,426 +17,28 @@ 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.DependencyInjection; -using Microsoft.IdentityModel.Tokens; using Xunit; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class JwtBearerTests + public class JwtBearerTests : SharedAuthenticationTests { - 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); + protected override string DefaultScheme => JwtBearerDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(JwtBearerHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - 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() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => + services.AddJwtBearer(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; + configure.Invoke(o); }); - - 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() + private void ConfigureDefaults(JwtBearerOptions o) { - var services = new ServiceCollection(); - services.AddAuthentication().AddJwtBearer(); - 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] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index e2e13f270..26a5484c8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -1,14 +1,5 @@ // 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; @@ -16,436 +7,42 @@ 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 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 Xunit; namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { - public class MicrosoftAccountTests + public class MicrosoftAccountTests : RemoteAuthenticationTests { - 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"; - }); + protected override string DefaultScheme => MicrosoftAccountDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(MicrosoftAccountHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - 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() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => + services.AddMicrosoftAccount(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; + configure.Invoke(o); }); - - 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() + protected override void ConfigureDefaults(MicrosoftAccountOptions o) { - 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() - { - 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() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddMicrosoftAccount(); - 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); + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 4b822b611..87131b8d7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -1,447 +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; -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 System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth { - public class OAuthTests + public class OAuthTests : RemoteAuthenticationTests { - [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); + protected override string DefaultScheme => OAuthDefaults.DisplayName; + protected override Type HandlerType => typeof(OAuthHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - 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 => + services.AddOAuth(DefaultScheme, o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; + configure.Invoke(o); }); - - 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() - { - var server = CreateServer( - services => services.AddAuthentication().AddOAuth("weeblie", o => - { - 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); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddOAuth("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(OAuthDefaults.DisplayName, scheme.DisplayName); } [Fact] @@ -654,7 +241,7 @@ public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwrittenWithBaseAuthe Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); } - private void ConfigureDefaults(OAuthOptions o) + protected override void ConfigureDefaults(OAuthOptions o) { o.ClientId = "Test Id"; o.ClientSecret = "secret"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs new file mode 100644 index 000000000..d477e7534 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.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 Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public abstract class RemoteAuthenticationTests : SharedAuthenticationTests where TOptions : RemoteAuthenticationOptions + { + protected override string DisplayName => DefaultScheme; + + private TestServer CreateServer(Action configureOptions, Func testpath = null, bool isDefault = true) + => CreateServerWithServices(s => + { + var builder = s.AddAuthentication(); + if (isDefault) + { + s.Configure(o => o.DefaultScheme = DefaultScheme); + } + RegisterAuth(builder, configureOptions); + s.AddSingleton(Clock); + }, testpath); + + + protected virtual TestServer CreateServerWithServices(Action configureServices, Func testpath = null) + { + //private static TestServer CreateServer(Action configure, Action configureServices, Func> handler) + var builder = new WebHostBuilder() + .Configure(app => + { + app.Use(async (context, next) => + { + if (testpath != null) + { + await testpath(context); + } + await next(); + }); + }) + .ConfigureServices(configureServices); + return new TestServer(builder); + } + + protected abstract void ConfigureDefaults(TOptions o); + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + o => + { + ConfigureDefaults(o); + o.SignInScheme = DefaultScheme; + }, + context => context.ChallengeAsync(DefaultScheme)); + 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( + o => o.SignInScheme = null, + context => context.ChallengeAsync(DefaultScheme), + isDefault: 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 = CreateServerWithServices( + services => + { + var builder = services.AddAuthentication(o => o.DefaultSignInScheme = DefaultScheme); + RegisterAuth(builder, o => o.SignInScheme = null); + }, + context => context.ChallengeAsync(DefaultScheme)); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs new file mode 100644 index 000000000..4590c4915 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs @@ -0,0 +1,510 @@ +// Copyright (c) .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.Tests; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public abstract class SharedAuthenticationTests where TOptions : AuthenticationSchemeOptions + { + protected TestClock Clock { get; } = new TestClock(); + + protected abstract string DefaultScheme { get; } + protected virtual string DisplayName { get; } + protected abstract Type HandlerType { get; } + + protected virtual bool SupportsSignIn { get => true; } + protected virtual bool SupportsSignOut { get => true; } + + protected abstract void RegisterAuth(AuthenticationBuilder services, Action configure); + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + }); + RegisterAuth(builder, 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); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + } + + [Fact] + public async Task ForwardSignInWinsOverDefault() + { + if (SupportsSignIn) + { + var services = new ServiceCollection().AddLogging(); + + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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() + { + if (SupportsSignOut) + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, selector.SignInCount); + } + else + { + 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + else + { + 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(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, 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); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + } + else + { + 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() + { + var services = new ServiceCollection(); + var builder = services.AddAuthentication(); + RegisterAuth(builder, o => { }); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(DefaultScheme); + Assert.NotNull(scheme); + Assert.Equal(HandlerType, scheme.HandlerType); + Assert.Equal(DisplayName, scheme.DisplayName); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index c1937d136..c438b1f3f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,5 +1,11 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +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 System; using System.Linq; using System.Net; @@ -7,438 +13,31 @@ 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; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter { - public class TwitterTests + public class TwitterTests : RemoteAuthenticationTests { - 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); + protected override string DefaultScheme => TwitterDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(TwitterHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignOutThrows() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => + services.AddTwitter(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; + configure.Invoke(o); }); - - 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() + protected override void ConfigureDefaults(TwitterOptions o) { - 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() - { - 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() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddTwitter(); - 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); + o.ConsumerKey = "whatever"; + o.ConsumerSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] From 860c187fca76e9d46a1158cec952d108cbfbc565 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 12:25:49 -0700 Subject: [PATCH 576/611] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 59 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f97a52471..49a994d6e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17099 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 + 2.2.0-preview1-17102 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 3.14.2 5.2.0 5.2.0 @@ -43,9 +43,10 @@ 2.0.3 11.0.2 5.2.0 - 0.9.0 + 0.10.0 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 27e2e80f9..6b8da29e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17099 -commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 +version:2.2.0-preview1-17102 +commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 From 2ddfd9ec4614df5f541525d063044f7ff8b07185 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 20:09:53 +0000 Subject: [PATCH 577/611] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 59 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index efaeec400..ed2f39082 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10011 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 + 3.0.0-alpha1-10015 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 3.14.2 5.2.0 5.2.0 @@ -43,9 +43,10 @@ 2.0.3 11.0.2 5.2.0 - 0.9.0 + 0.10.0 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9a67ee9c2..1e75dc3a2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10011 -commithash:717c2eb1f91dafd2580c1a9b8e5064d12dd8c054 +version:3.0.0-alpha1-10015 +commithash:3f36e5c2f061712f76f2766c435d2555681d5c55 From 1e14a22e0dfe3ebc9c1ddadb69585cee8df471f6 Mon Sep 17 00:00:00 2001 From: Wouter Date: Tue, 31 Jul 2018 13:40:49 +0200 Subject: [PATCH 578/611] Change description of role in RequireRole method The description of the pram roles feels ambiguous. Make it clear that the user should belong to one of the roles and not all of them. As documented: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-2.1 --- .../AuthorizationPolicyBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 37335df8f..c2fd22afb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -147,7 +147,7 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType) /// Adds a /// to the current instance. /// - /// The roles required. + /// The allowed roles. /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(params string[] roles) { @@ -163,7 +163,7 @@ public AuthorizationPolicyBuilder RequireRole(params string[] roles) /// Adds a /// to the current instance. /// - /// The roles required. + /// The allowed roles. /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(IEnumerable roles) { @@ -247,4 +247,4 @@ public AuthorizationPolicy Build() return new AuthorizationPolicy(Requirements, AuthenticationSchemes.Distinct()); } } -} \ No newline at end of file +} From fd9255d1465cad37656f92bec6b45c212b0ac043 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 19:26:51 +0000 Subject: [PATCH 579/611] 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 49a994d6e..0e02888f1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17102 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 + 2.2.0-preview1-20180731.1 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6b8da29e6..c7af2292c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17102 -commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 +version:2.2.0-preview1-20180731.1 +commithash:29fde58465439f4bb9df40830635ed758e063daf From 9f44ef5b5628f3cb5f02d9c7ccc1df6d74fee90b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 20:04:32 +0000 Subject: [PATCH 580/611] 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 ed2f39082..5f1d18e29 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10015 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 + 3.0.0-alpha1-20180731.2 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1e75dc3a2..8f9f6066e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10015 -commithash:3f36e5c2f061712f76f2766c435d2555681d5c55 +version:3.0.0-alpha1-20180731.2 +commithash:1179f1083695ac9213c8a70a4d1d6c45a52caf41 From 899dce9960ee8426c6615f597a977e40065dce97 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 6 Aug 2018 20:50:20 +0000 Subject: [PATCH 581/611] 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 0e02888f1..c195a895e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 3.14.2 5.2.0 5.2.0 From ef80c3beb72ee37ed8f525f627912f1efcede663 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 19:28:50 +0000 Subject: [PATCH 582/611] 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 c195a895e..100236d46 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 + 2.2.0-preview1-20180807.2 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c7af2292c..3fbcc8018 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180731.1 -commithash:29fde58465439f4bb9df40830635ed758e063daf +version:2.2.0-preview1-20180807.2 +commithash:11495dbd236104434e08cb1152fcb58cf2a20923 From f084067d6a255fde3d12c07988157311ba52c51a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 20:14:03 +0000 Subject: [PATCH 583/611] 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 5f1d18e29..6c563e9b7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180731.2 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 + 3.0.0-alpha1-20180810.1 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8f9f6066e..e417a01b5 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180731.2 -commithash:1179f1083695ac9213c8a70a4d1d6c45a52caf41 +version:3.0.0-alpha1-20180810.1 +commithash:45c32b4f020e14a9295be31866051a18d293309d From 79f8442ce2e37aa506433fe6cfa4df9e31b601a5 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 19 Aug 2018 19:28:38 +0000 Subject: [PATCH 584/611] 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 6c563e9b7..6cf929cc2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180810.1 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 + 3.0.0-alpha1-20180817.3 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e417a01b5..e5330b3d3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180810.1 -commithash:45c32b4f020e14a9295be31866051a18d293309d +version:3.0.0-alpha1-20180817.3 +commithash:134cdbee9bee29dd3ccb654c67663b27b9ffa6c8 From 1cb07e1019493faa9ad5a1ae6f3b4937620e249c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 21 Aug 2018 13:33:52 -0700 Subject: [PATCH 585/611] Update package branding for 2.2.0-preview2 --- 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 100236d46..51881441d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -47,6 +47,6 @@ 2.3.1 2.4.0 - +
diff --git a/version.props b/version.props index 44985cedb..15637ba78 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 7a7dcec569619e40c1f2e2996333aeb10c1f5ad5 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 26 Aug 2018 19:28:22 +0000 Subject: [PATCH 586/611] 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 6cf929cc2..f89ecc205 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180817.3 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 + 3.0.0-alpha1-20180821.3 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e5330b3d3..767a47179 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180817.3 -commithash:134cdbee9bee29dd3ccb654c67663b27b9ffa6c8 +version:3.0.0-alpha1-20180821.3 +commithash:0939a90812deb1c604eb9a4768869687495fc1dd From c6f5786418c2478dfc7f5a604d8b65911f9f0c1b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 12:26:16 -0700 Subject: [PATCH 587/611] 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 51881441d..b0386a923 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180807.2 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 + 2.2.0-preview1-20180821.1 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3fbcc8018..ad704918d 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180807.2 -commithash:11495dbd236104434e08cb1152fcb58cf2a20923 +version:2.2.0-preview1-20180821.1 +commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 From e2a07fbddcc5b1d9fb45ed94159f88fda87cbe0c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 19:27:32 +0000 Subject: [PATCH 588/611] 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 f89ecc205..be569db69 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 3.14.2 5.2.0 5.2.0 From ff479de7b185269bd3dc8310a0ef46c3c539e02b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 5 Sep 2018 16:36:16 -0700 Subject: [PATCH 589/611] Update branding to 2.2.0-preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 15637ba78..704cac087 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From f8959fd6a842cb325a09cc99efee82d05ae6a202 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 6 Sep 2018 00:00:16 +0000 Subject: [PATCH 590/611] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index be569db69..a6108f771 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,38 +4,38 @@ 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 3.14.2 5.2.0 5.2.0 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 3.0.1 3.0.1 From 6ec79a3dd33ab60ba5f5dd6cde34f13f23c2a786 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:28:32 -0700 Subject: [PATCH 591/611] 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 b0386a923..de9d4de79 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180821.1 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 3.14.2 5.2.0 5.2.0 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index ad704918d..312f82f9a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180821.1 -commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From 5cd5de3bb8558c61f02b29c3979e5f71af98cc70 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 19:29:49 +0000 Subject: [PATCH 592/611] 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 a6108f771..4245f2fd4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 + 3.0.0-alpha1-20180907.9 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 767a47179..b614cab6e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180821.3 -commithash:0939a90812deb1c604eb9a4768869687495fc1dd +version:3.0.0-alpha1-20180907.9 +commithash:f997365a8832ff0a3cbd9a98df45734ac2723fa0 From b3ad10ef517b367e29511d252b0a999bda2ba86e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 12:27:11 -0700 Subject: [PATCH 593/611] 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 de9d4de79..e6a11ccd7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.8 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 + 2.2.0-preview1-20180911.1 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 312f82f9a..7124f3744 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.8 -commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 +version:2.2.0-preview1-20180911.1 +commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 From 7b6c9cf0eeb149f2142dedd55a17430e7831ea99 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 19:29:05 +0000 Subject: [PATCH 594/611] 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 4245f2fd4..a9ec2c341 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180907.9 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 + 3.0.0-alpha1-20180911.2 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b614cab6e..a817c10d2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180907.9 -commithash:f997365a8832ff0a3cbd9a98df45734ac2723fa0 +version:3.0.0-alpha1-20180911.2 +commithash:2a2b7dbea1b247930c41da497f4ea0b2bb756818 From 9c7f0b0b0d664c3c9e0cb045a4749c07a7be2d2e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 12:27:28 -0700 Subject: [PATCH 595/611] 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 a9ec2c341..2fab2c7bf 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180911.2 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 + 3.0.0-alpha1-20180919.1 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a817c10d2..d66a13bdc 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180911.2 -commithash:2a2b7dbea1b247930c41da497f4ea0b2bb756818 +version:3.0.0-alpha1-20180919.1 +commithash:3066ae0a230870ea07e3f132605b5e5493f8bbd4 From 862f78122885cdb725d4a25f8ce07e34ccb860f4 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 19:30:15 +0000 Subject: [PATCH 596/611] 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 e6a11ccd7..04b0266a5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180911.1 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 + 2.2.0-preview1-20180918.1 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7124f3744..649bf2ba0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180911.1 -commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 +version:2.2.0-preview1-20180918.1 +commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 From 383201902731f07041b9fdc73256b0859d1c3660 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 25 Sep 2018 13:56:58 -0700 Subject: [PATCH 597/611] Update Facebook to v3.1 endpoints #92 --- samples/SocialSample/Startup.cs | 6 ++++++ .../FacebookDefaults.cs | 7 ++++--- .../FacebookOptions.cs | 1 - .../GoogleDefaults.cs | 2 ++ .../MicrosoftAccountDefaults.cs | 1 + .../TwitterDefaults.cs | 9 +++++++++ .../TwitterHandler.cs | 9 +++------ .../FacebookTests.cs | 6 +++--- 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 35896e84b..b5032072b 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -59,6 +59,7 @@ public void ConfigureServices(IServiceCollection services) .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/ + // https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login .AddFacebook(o => { o.AppId = Configuration["facebook:appid"]; @@ -74,6 +75,8 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project + // https://developers.google.com/identity/protocols/OAuth2WebServer + // https://developers.google.com/+/web/people/ .AddOAuth("Google-AccessToken", "Google AccessToken only", o => { o.ClientId = Configuration["google:clientid"]; @@ -92,6 +95,8 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project + // https://developers.google.com/identity/protocols/OAuth2WebServer + // https://developers.google.com/+/web/people/ .AddGoogle(o => { o.ClientId = Configuration["google:clientid"]; @@ -108,6 +113,7 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Twitter and add its key and Secret to your user-secrets. // https://apps.twitter.com/ + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/access_token .AddTwitter(o => { o.ConsumerKey = Configuration["twitter:consumerkey"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 92d1d003e..ff9bb40bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -9,10 +9,11 @@ public static class FacebookDefaults public static readonly string DisplayName = "Facebook"; - public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.12/dialog/oauth"; + // https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v3.1/dialog/oauth"; - public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.12/oauth/access_token"; + public static readonly string TokenEndpoint = "https://graph.facebook.com/v3.1/oauth/access_token"; - public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.12/me"; + public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v3.1/me"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index 7010bb20a..c2078a017 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -26,7 +26,6 @@ public FacebookOptions() AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; TokenEndpoint = FacebookDefaults.TokenEndpoint; UserInformationEndpoint = FacebookDefaults.UserInformationEndpoint; - Scope.Add("public_profile"); Scope.Add("email"); Fields.Add("name"); Fields.Add("email"); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index 042870318..26b3b8f01 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -12,10 +12,12 @@ public static class GoogleDefaults public static readonly string DisplayName = "Google"; + // https://developers.google.com/identity/protocols/OAuth2WebServer 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"; + // https://developers.google.com/+/web/people/ public static readonly string UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index 1b0859c5b..0421fa14b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -9,6 +9,7 @@ public static class MicrosoftAccountDefaults public static readonly string DisplayName = "Microsoft"; + // https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_user 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.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs index a39a3f036..bdab80e59 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs @@ -8,5 +8,14 @@ public static class TwitterDefaults public const string AuthenticationScheme = "Twitter"; public static readonly string DisplayName = "Twitter"; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/request_token + internal const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate + internal const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/access_token + internal const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index d0d54bf74..51dabbd99 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -22,9 +22,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter 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"; - private const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; - private const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; private HttpClient Backchannel => Options.Backchannel; @@ -138,7 +135,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // If CallbackConfirmed is false, this will throw var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); - var twitterAuthenticationEndpoint = AuthenticationEndpoint + requestToken.Token; + var twitterAuthenticationEndpoint = TwitterDefaults.AuthenticationEndpoint + requestToken.Token; var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); @@ -233,7 +230,7 @@ private async Task ObtainRequestTokenAsync(string callBackUri, Aut { Logger.ObtainRequestToken(); - var response = await ExecuteRequestAsync(RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); + var response = await ExecuteRequestAsync(TwitterDefaults.RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); @@ -253,7 +250,7 @@ private async Task ObtainAccessTokenAsync(RequestToken token, strin Logger.ObtainAccessToken(); var formPost = new Dictionary { { "oauth_verifier", verifier } }; - var response = await ExecuteRequestAsync(AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); + var response = await ExecuteRequestAsync(TwitterDefaults.AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); if (!response.IsSuccessStatusCode) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b909be9fd..0a5440e40 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -673,7 +673,7 @@ public async Task NestedMapWillNotAffectRedirect() 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.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/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); @@ -705,7 +705,7 @@ public async Task MapWillNotAffectRedirect() 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.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/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); @@ -739,7 +739,7 @@ public async Task ChallengeWillTriggerRedirection() 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.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); From 59bbd966902fa195c8bbd0a168475bb361bc9aa7 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 27 Sep 2018 15:22:42 -0700 Subject: [PATCH 598/611] Update LICENSE.txt --- LICENSE.txt | 207 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 197 insertions(+), 10 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 7b2956ece..b3b180cd5 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,14 +1,201 @@ -Copyright (c) .NET Foundation and Contributors + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -All rights reserved. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -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 + 1. Definitions. - http://www.apache.org/licenses/LICENSE-2.0 + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -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. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) .NET Foundation and Contributors + + 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. From b16af1600ed04f47396bca86cb0f5f73490bf1cd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 17:10:39 -0700 Subject: [PATCH 599/611] automated: bulk infrastructure updates. Update bootstrapper scripts and remove unnecessary signing properties --- Directory.Build.props | 3 --- run.ps1 | 6 +++--- run.sh | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 91cd995d7..eb9d9535e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,9 +14,6 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true - Microsoft - MicrosoftNuGet - true true diff --git a/run.ps1 b/run.ps1 index 3b2738246..34604c717 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac1587..4c1fed564 100755 --- a/run.sh +++ b/run.sh @@ -220,7 +220,7 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python ; then @@ -228,7 +228,7 @@ if [ -f "$config_file" ]; 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 - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python3 ; then @@ -236,11 +236,11 @@ if [ -f "$config_file" ]; then config_channel="$(python3 -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="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi else - _error 'Missing required command: jq or python. Could not parse the JSON file.' + __error 'Missing required command: jq or python. Could not parse the JSON file.' exit 1 fi @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From 564d53641ddba29f502d350cd4a95484b313acd9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:27:37 -0700 Subject: [PATCH 600/611] 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 bcac6f0ec..b83428bb6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 3.0.0-alpha1-20180919.1 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 3.14.2 5.2.0 5.2.0 From 889abf6f6ec4119dbd27c1a8d07a7566e0e91627 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:30:31 -0700 Subject: [PATCH 601/611] 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 04b0266a5..5582bc18f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180918.1 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 + 2.2.0-preview1-20180928.5 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 3.14.2 5.2.0 5.2.0 2.0.9 2.1.3 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-26927-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 649bf2ba0..26697a21f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180918.1 -commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 +version:2.2.0-preview1-20180928.5 +commithash:43faa29f679f47b88689d645b39e6be5e0055d70 From ecfb19993a3ed965de2a7738b597949924ca88d1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 12:29:16 -0700 Subject: [PATCH 602/611] 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 b83428bb6..6b6523c76 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180919.1 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 + 3.0.0-alpha1-20181004.7 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d66a13bdc..591cfd52f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180919.1 -commithash:3066ae0a230870ea07e3f132605b5e5493f8bbd4 +version:3.0.0-alpha1-20181004.7 +commithash:27fabdaf2b1d4753c3d2749581694ca65d78f7f2 From fcfa161cb7db735dfb4c386237b5858a4dc5926b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 19:31:54 +0000 Subject: [PATCH 603/611] 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 5582bc18f..0d1a80ebb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180928.5 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 2.2.0-preview2-20181004.6 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 3.14.2 5.2.0 5.2.0 2.0.9 2.1.3 - 2.2.0-preview3-26927-02 + 2.2.0-preview3-27001-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 26697a21f..96fe3217e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180928.5 -commithash:43faa29f679f47b88689d645b39e6be5e0055d70 +version:2.2.0-preview2-20181004.6 +commithash:c04c4b2f5018632647f96210ab01876661302dac From 5d5438a7f0842019e852b2bb911ed86dc0360cf7 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 11 Oct 2018 15:27:24 -0700 Subject: [PATCH 604/611] Relax test SkuTelemetry strictness #1875 --- .../OpenIdConnect/TestSettings.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index b32e0723f..eb045b438 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -195,7 +195,7 @@ private void ValidateParameters( ValidateState(actualValues, errors, htmlEncoded); break; case OpenIdConnectParameterNames.SkuTelemetry: - ValidateSkuTelemetry(actualValues, errors, htmlEncoded); + ValidateSkuTelemetry(actualValues, errors); break; case OpenIdConnectParameterNames.VersionTelemetry: ValidateVersionTelemetry(actualValues, errors, htmlEncoded); @@ -258,14 +258,13 @@ private void ValidateResource(IDictionary actualParams, ICollect private void ValidateState(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); - private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_2 - 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 static void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors) + { + if (!actualParams.ContainsKey(OpenIdConnectParameterNames.SkuTelemetry)) + { + errors.Add($"Parameter {OpenIdConnectParameterNames.SkuTelemetry} is missing"); + } + } private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); From 32177cad1eb1eb6be8ad89a7dba1a1637c0d0786 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 22 Oct 2018 23:50:52 -0500 Subject: [PATCH 605/611] Added missing Div tag in JwtBearer sample. (#1888) --- samples/JwtBearerSample/wwwroot/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/JwtBearerSample/wwwroot/index.html b/samples/JwtBearerSample/wwwroot/index.html index f71dccb69..4715ebd42 100644 --- a/samples/JwtBearerSample/wwwroot/index.html +++ b/samples/JwtBearerSample/wwwroot/index.html @@ -64,5 +64,6 @@

Todo List

+ From cb83e4f48502057176b62d53e98de1d43db44a33 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 8 Nov 2018 15:42:35 +1300 Subject: [PATCH 606/611] Authorization middleware (#1894) --- .gitignore | 1 + Security.sln | 21 + .../AuthorizationMiddlewareBenchmark.cs | 53 ++ .../AuthorizationPolicyBenchmark.cs | 28 ++ ...oft.AspNetCore.Security.Performance.csproj | 24 + .../Properties/AssemblyInfo.cs | 1 + .../readme.md | 16 + build/dependencies.props | 67 +-- .../AuthorizationAppBuilderExtensions.cs | 29 ++ ...tionEndpointConventionBuilderExtensions.cs | 50 ++ .../AuthorizationMiddleware.cs | 104 ++++ ...oft.AspNetCore.Authorization.Policy.csproj | 4 +- .../AuthorizationOptions.cs | 16 +- .../AuthorizationPolicy.cs | 84 ++-- .../DefaultAuthorizationPolicyProvider.cs | 23 +- .../IAuthorizationPolicyProvider.cs | 6 + .../AuthorizationAppBuilderExtensionsTests.cs | 65 +++ ...ndpointConventionBuilderExtensionsTests.cs | 63 +++ .../AuthorizationMiddlewareTests.cs | 459 ++++++++++++++++++ .../DefaultAuthorizationServiceTests.cs | 10 + ...osoft.AspNetCore.Authorization.Test.csproj | 3 + .../TestObjects/TestAuthenticationService.cs | 58 +++ 22 files changed, 1122 insertions(+), 63 deletions(-) create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs diff --git a/.gitignore b/.gitignore index d5717b3f3..3d7e16e84 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ project.lock.json /.vs/ .vscode/ global.json +BenchmarkDotNet.Artifacts/ diff --git a/Security.sln b/Security.sln index 3df759651..240100e8c 100644 --- a/Security.sln +++ b/Security.sln @@ -79,6 +79,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WsFedSample", "samples\WsFedSample\WsFedSample.csproj", "{5EC2E398-E46A-430D-8E4B-E91C8FC3E800}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{55052FE3-F8C2-4E6C-97B0-C02ED1DBEA62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Security.Performance", "benchmarks\Microsoft.AspNetCore.Security.Performance\Microsoft.AspNetCore.Security.Performance.csproj", "{556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -517,6 +521,22 @@ Global {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 + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x64.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x64.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x86.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x86.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Any CPU.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x64.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x64.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x86.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -549,6 +569,7 @@ Global {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} + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A} = {55052FE3-F8C2-4E6C-97B0-C02ED1DBEA62} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs new file mode 100644 index 000000000..90cb135de --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs @@ -0,0 +1,53 @@ +// Copyright (c) .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 BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Security +{ + public class AuthorizationMiddlewareBenchmark + { + private AuthorizationMiddleware _authorizationMiddleware; + private DefaultHttpContext _httpContextNoEndpoint; + private DefaultHttpContext _httpContextHasEndpoint; + + [GlobalSetup] + public void Setup() + { + var policyProvider = new DefaultAuthorizationPolicyProvider(Options.Create(new AuthorizationOptions())); + _authorizationMiddleware = new AuthorizationMiddleware((context) => Task.CompletedTask, policyProvider); + + _httpContextNoEndpoint = new DefaultHttpContext(); + + var feature = new EndpointFeature + { + Endpoint = new Endpoint((context) => Task.CompletedTask, EndpointMetadataCollection.Empty, "Test endpoint") + }; + _httpContextHasEndpoint = new DefaultHttpContext(); + _httpContextHasEndpoint.Features.Set(feature); + } + + [Benchmark] + public Task Invoke_NoEndpoint_NoAuthorization() + { + return _authorizationMiddleware.Invoke(_httpContextNoEndpoint); + } + + [Benchmark] + public Task Invoke_HasEndpoint_NoAuthorization() + { + return _authorizationMiddleware.Invoke(_httpContextHasEndpoint); + } + + private class EndpointFeature : IEndpointFeature + { + public Endpoint Endpoint { get; set; } + } + } +} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs new file mode 100644 index 000000000..86afdcd5a --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.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; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Security +{ + public class AuthorizationPolicyBenchmark + { + private DefaultAuthorizationPolicyProvider _policyProvider; + + [GlobalSetup] + public void Setup() + { + _policyProvider = new DefaultAuthorizationPolicyProvider(Options.Create(new AuthorizationOptions())); + } + + [Benchmark] + public Task CombineAsync() + { + return AuthorizationPolicy.CombineAsync(_policyProvider, Array.Empty()); + } + } +} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj new file mode 100644 index 000000000..7226b64be --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.2 + Exe + true + true + false + Microsoft.AspNetCore.Security + + + + + + + + + + + + + + + diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..cfb0b19c2 --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: BenchmarkDotNet.Attributes.AspNetCoreBenchmark] \ No newline at end of file diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md b/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md new file mode 100644 index 000000000..cbe60261b --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md @@ -0,0 +1,16 @@ +Compile the solution in Release mode (so binaries are available in release) + +To run a specific benchmark add it as parameter. +``` +dotnet run -c Release --framework +``` + +To run all benchmarks use '*' as the name. +``` +dotnet run -c Release --framework * +``` + +If you run without any parameters, you'll be offered the list of all benchmarks and get to choose. +``` +dotnet run -c Release --framework +``` \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index a870f2f49..230a942c0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,46 +3,51 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ 0.10.13 3.0.0-alpha1-20181004.7 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.14.2 - 5.2.0 - 5.2.0 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10657 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-a-alpha1-endpoint-extensions-namespace-16778 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.19.8 + 5.3.0 + 5.3.0 2.0.9 2.1.3 - 2.2.0-preview3-27001-02 + 2.2.0-rtm-27105-02 15.6.1 3.0.1 3.0.1 3.0.1 + 4.10.0 2.0.3 11.0.2 - 5.2.0 + 5.3.0 0.10.0 2.3.1 2.4.0 diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs new file mode 100644 index 000000000..66f0eb6f1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.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.Authorization; + +namespace Microsoft.AspNetCore.Builder +{ + /// + /// Extension methods to add authorization capabilities to an HTTP application pipeline. + /// + public static class AuthorizationAppBuilderExtensions + { + /// + /// Adds the to the specified , which enables authorization capabilities. + /// + /// The to add the middleware to. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseAuthorization(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + return app.UseMiddleware(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs new file mode 100644 index 000000000..81b05d70a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.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; +using System.Linq; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Routing; + +namespace Microsoft.AspNetCore.Builder +{ + public static class AuthorizationEndpointConventionBuilderExtensions + { + public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params IAuthorizeData[] authorizeData) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (authorizeData == null) + { + throw new ArgumentNullException(nameof(authorizeData)); + } + + builder.Apply(endpointBuilder => + { + foreach (var data in authorizeData) + { + endpointBuilder.Metadata.Add(data); + } + }); + return builder; + } + + public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params string[] policyNames) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (policyNames == null) + { + throw new ArgumentNullException(nameof(policyNames)); + } + + return builder.RequireAuthorization(policyNames.Select(n => new AuthorizeAttribute(n)).ToArray()); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs new file mode 100644 index 000000000..1da5b123f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs @@ -0,0 +1,104 @@ +// Copyright (c) .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.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization.Policy; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.Authorization +{ + public class AuthorizationMiddleware + { + private readonly RequestDelegate _next; + private readonly IAuthorizationPolicyProvider _policyProvider; + + public AuthorizationMiddleware(RequestDelegate next, IAuthorizationPolicyProvider policyProvider) + { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (policyProvider == null) + { + throw new ArgumentNullException(nameof(policyProvider)); + } + + _next = next; + _policyProvider = policyProvider; + } + + public async Task Invoke(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var endpoint = context.GetEndpoint(); + var authorizeData = endpoint?.Metadata.GetOrderedMetadata() ?? Array.Empty(); + var policy = await AuthorizationPolicy.CombineAsync(_policyProvider, authorizeData); + if (policy == null) + { + await _next(context); + return; + } + + // Policy evaluator has transient lifetime so it fetched from request services instead of injecting in constructor + var policyEvaluator = context.RequestServices.GetRequiredService(); + + var authenticateResult = await policyEvaluator.AuthenticateAsync(policy, context); + + // Allow Anonymous skips all authorization + if (endpoint?.Metadata.GetMetadata() != null) + { + await _next(context); + return; + } + + // Note that the resource will be null if there is no matched endpoint + var authorizeResult = await policyEvaluator.AuthorizeAsync(policy, authenticateResult, context, resource: endpoint); + + if (authorizeResult.Challenged) + { + if (policy.AuthenticationSchemes.Any()) + { + foreach (var scheme in policy.AuthenticationSchemes) + { + await context.ChallengeAsync(scheme); + } + } + else + { + await context.ChallengeAsync(); + } + + return; + } + else if (authorizeResult.Forbidden) + { + if (policy.AuthenticationSchemes.Any()) + { + foreach (var scheme in policy.AuthenticationSchemes) + { + await context.ForbidAsync(scheme); + } + } + else + { + await context.ForbidAsync(); + } + + return; + } + + await _next(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 index 16e4aa262..aba88dd50 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -3,7 +3,7 @@ ASP.NET Core authorization policy helper classes. netstandard2.0 - $(NoWarn);CS1591 + $(NoWarn);CS1591;NU1605 true aspnetcore;authorization @@ -14,6 +14,8 @@ + + diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index 6899913af..f0c5527d2 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -20,13 +20,25 @@ public class AuthorizationOptions public bool InvokeHandlersAfterFailure { get; set; } = true; /// - /// Gets or sets the default authorization policy. + /// Gets or sets the default authorization policy. Defaults to require authenticated users. /// /// - /// The default policy is to require any authenticated user. + /// The default policy used when evaluating with no policy name specified. /// public AuthorizationPolicy DefaultPolicy { get; set; } = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + /// + /// Gets or sets the required authorization policy. Defaults to null. + /// + /// + /// By default the required policy is null. + /// + /// If a required policy has been specified then it is always evaluated, even if there are no + /// instances for a resource. If a resource has + /// then they are evaluated together with the required policy. + /// + public AuthorizationPolicy RequiredPolicy { get; set; } + /// /// Add an authorization policy with the provided name. /// diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 36e0ca7c3..b3b54f300 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -120,46 +120,74 @@ public static async Task CombineAsync(IAuthorizationPolicyP throw new ArgumentNullException(nameof(authorizeData)); } - var policyBuilder = new AuthorizationPolicyBuilder(); - var any = false; - foreach (var authorizeDatum in authorizeData) + // Avoid allocating enumerator if the data is known to be empty + var skipEnumeratingData = false; + if (authorizeData is IList dataList) { - any = true; - var useDefaultPolicy = true; - if (!string.IsNullOrWhiteSpace(authorizeDatum.Policy)) + skipEnumeratingData = dataList.Count == 0; + } + + AuthorizationPolicyBuilder policyBuilder = null; + if (!skipEnumeratingData) + { + foreach (var authorizeDatum in authorizeData) { - var policy = await policyProvider.GetPolicyAsync(authorizeDatum.Policy); - if (policy == null) + if (policyBuilder == null) { - throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeDatum.Policy)); + policyBuilder = new AuthorizationPolicyBuilder(); } - policyBuilder.Combine(policy); - useDefaultPolicy = false; - } - 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 = authorizeDatum.AuthenticationSchemes?.Split(','); - if (authTypesSplit != null && authTypesSplit.Any()) - { - foreach (var authType in authTypesSplit) + + var useDefaultPolicy = true; + if (!string.IsNullOrWhiteSpace(authorizeDatum.Policy)) + { + var policy = await policyProvider.GetPolicyAsync(authorizeDatum.Policy); + if (policy == null) + { + throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeDatum.Policy)); + } + policyBuilder.Combine(policy); + useDefaultPolicy = false; + } + + 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 = authorizeDatum.AuthenticationSchemes?.Split(','); + if (authTypesSplit != null && authTypesSplit.Any()) { - if (!string.IsNullOrWhiteSpace(authType)) + foreach (var authType in authTypesSplit) { - policyBuilder.AuthenticationSchemes.Add(authType.Trim()); + if (!string.IsNullOrWhiteSpace(authType)) + { + policyBuilder.AuthenticationSchemes.Add(authType.Trim()); + } } } + + if (useDefaultPolicy) + { + policyBuilder.Combine(await policyProvider.GetDefaultPolicyAsync()); + } } - if (useDefaultPolicy) + } + + var requiredPolicy = await policyProvider.GetRequiredPolicyAsync(); + if (requiredPolicy != null) + { + if (policyBuilder == null) { - policyBuilder.Combine(await policyProvider.GetDefaultPolicyAsync()); + policyBuilder = new AuthorizationPolicyBuilder(); } + + policyBuilder.Combine(requiredPolicy); } - return any ? policyBuilder.Build() : null; + + return policyBuilder?.Build(); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index 0e4329dcc..f5e665273 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Authorization public class DefaultAuthorizationPolicyProvider : IAuthorizationPolicyProvider { private readonly AuthorizationOptions _options; + private Task _cachedDefaultPolicy; + private Task _cachedRequiredPolicy; /// /// Creates a new instance of . @@ -35,7 +37,26 @@ public DefaultAuthorizationPolicyProvider(IOptions options /// The default authorization policy. public Task GetDefaultPolicyAsync() { - return Task.FromResult(_options.DefaultPolicy); + return GetCachedPolicy(ref _cachedDefaultPolicy, _options.DefaultPolicy); + } + + /// + /// Gets the required authorization policy. + /// + /// The required authorization policy. + public Task GetRequiredPolicyAsync() + { + return GetCachedPolicy(ref _cachedRequiredPolicy, _options.RequiredPolicy); + } + + private Task GetCachedPolicy(ref Task cachedPolicy, AuthorizationPolicy currentPolicy) + { + var local = cachedPolicy; + if (local == null || local.Result != currentPolicy) + { + cachedPolicy = local = Task.FromResult(currentPolicy); + } + return local; } /// diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs index 9e9d0f468..4560d11e0 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -22,5 +22,11 @@ public interface IAuthorizationPolicyProvider /// /// The default authorization policy. Task GetDefaultPolicyAsync(); + + /// + /// Gets the required authorization policy. + /// + /// The required authorization policy. + Task GetRequiredPolicyAsync(); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs new file mode 100644 index 000000000..c6fb596f1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.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.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization.Test.TestObjects; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder.Internal; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationAppBuilderExtensionsTests + { + [Fact] + public async Task UseAuthorization_RegistersMiddleware() + { + // Arrange + var authenticationService = new TestAuthenticationService(); + var services = CreateServices(authenticationService); + + var app = new ApplicationBuilder(services); + + app.UseAuthorization(); + + var appFunc = app.Build(); + + var endpoint = new Endpoint( + null, + new EndpointMetadataCollection(new AuthorizeAttribute()), + "Test endpoint"); + + var httpContext = new DefaultHttpContext(); + httpContext.RequestServices = services; + httpContext.SetEndpoint(endpoint); + + // Act + await appFunc(httpContext); + + // Assert + Assert.True(authenticationService.ChallengeCalled); + } + + private IServiceProvider CreateServices(IAuthenticationService authenticationService) + { + var services = new ServiceCollection(); + + services.AddAuthorization(options => { }); + services.AddAuthorizationPolicyEvaluator(); + services.AddLogging(); + services.AddSingleton(authenticationService); + + var serviceProvder = services.BuildServiceProvider(); + + return serviceProvder; + } + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs new file mode 100644 index 000000000..a2ab8fa8b --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.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.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Routing.Patterns; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationEndpointConventionBuilderExtensionsTests + { + [Fact] + public void RequireAuthorization_IAuthorizeData() + { + // Arrange + var builder = new TestEndpointConventionBuilder(); + var metadata = new AuthorizeAttribute(); + + // Act + builder.RequireAuthorization(metadata); + + // Assert + var convention = Assert.Single(builder.Conventions); + + var endpointModel = new RouteEndpointModel((context) => Task.CompletedTask, RoutePatternFactory.Parse("/"), 0); + convention(endpointModel); + + Assert.Equal(metadata, Assert.Single(endpointModel.Metadata)); + } + + [Fact] + public void RequireAuthorization_PolicyName() + { + // Arrange + var builder = new TestEndpointConventionBuilder(); + + // Act + builder.RequireAuthorization("policy"); + + // Assert + var convention = Assert.Single(builder.Conventions); + + var endpointModel = new RouteEndpointModel((context) => Task.CompletedTask, RoutePatternFactory.Parse("/"), 0); + convention(endpointModel); + + Assert.Equal("policy", Assert.IsAssignableFrom(Assert.Single(endpointModel.Metadata)).Policy); + } + + private class TestEndpointConventionBuilder : IEndpointConventionBuilder + { + public IList> Conventions { get; } = new List>(); + + public void Apply(Action convention) + { + Conventions.Add(convention); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs new file mode 100644 index 000000000..655a4fbf8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs @@ -0,0 +1,459 @@ +// Copyright (c) .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.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization.Test.TestObjects; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationMiddlewareTests + { + [Fact] + public async Task NoEndpoint_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task NoEndpointWithRequired_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + } + + [Fact] + public async Task HasEndpointWithoutAuth_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint()); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task HasEndpointWithRequiredWithoutAuth_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint()); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + } + + [Fact] + public async Task HasEndpointWithAuth_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.True(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task HasEndpointWithAuth_AnonymousUser_ChallengePerScheme() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().AddAuthenticationSchemes("schema1", "schema2").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.Equal(2, authenticationService.ChallengeCount); + } + + [Fact] + public async Task OnAuthorizationAsync_WillCallPolicyProvider() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policyProvider = new Mock(); + var getPolicyCount = 0; + var getRequiredPolicyCount = 0; + policyProvider.Setup(p => p.GetPolicyAsync(It.IsAny())).ReturnsAsync(policy) + .Callback(() => getPolicyCount++); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy) + .Callback(() => getRequiredPolicyCount++); + var next = new TestRequestDelegate(); + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute("whatever"))); + + // Act & Assert + await middleware.Invoke(context); + Assert.Equal(1, getPolicyCount); + Assert.Equal(1, getRequiredPolicyCount); + Assert.Equal(1, next.CalledCount); + + await middleware.Invoke(context); + Assert.Equal(2, getPolicyCount); + Assert.Equal(2, getRequiredPolicyCount); + Assert.Equal(2, next.CalledCount); + + await middleware.Invoke(context); + Assert.Equal(3, getPolicyCount); + Assert.Equal(3, getRequiredPolicyCount); + Assert.Equal(3, next.CalledCount); + } + + [Fact] + public async Task Invoke_ValidClaimShouldNotFail() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute())); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task HasEndpointWithAuthAndAllowAnonymous_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute(), new AllowAnonymousAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + Assert.False(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task HasEndpointWithAuth_AuthenticatedUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + Assert.False(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task Invoke_AuthSchemesFailShouldSetEmptyPrincipalOnContext() + { + // Arrange + var policy = new AuthorizationPolicyBuilder("Fails").RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.NotNull(context.User?.Identity); + Assert.True(authenticationService.AuthenticateCalled); + Assert.True(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task Invoke_SingleValidClaimShouldSucceed() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewComment", "CanViewPage").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute())); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task AuthZResourceShouldBeEndpoint() + { + // Arrange + object resource = null; + var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => + { + resource = c.Resource; + return true; + }).Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var endpoint = CreateEndpoint(new AuthorizeAttribute()); + var context = GetHttpContext(endpoint: endpoint); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.Equal(endpoint, resource); + } + + [Fact] + public async Task Invoke_RequireUnknownRoleShouldForbid() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.False(authenticationService.ChallengeCalled); + Assert.True(authenticationService.ForbidCalled); + } + + [Fact] + public async Task Invoke_RequireUnknownRole_ForbidPerScheme() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").AddAuthenticationSchemes("Basic", "Bearer").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.Equal(2, authenticationService.ForbidCount); + } + + [Fact] + public async Task Invoke_InvalidClaimShouldForbid() + { + // Arrange + var policy = new AuthorizationPolicyBuilder() + .RequireClaim("Permission", "CanViewComment") + .Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.False(authenticationService.ChallengeCalled); + Assert.True(authenticationService.ForbidCalled); + } + + private AuthorizationMiddleware CreateMiddleware(RequestDelegate requestDelegate = null, IAuthorizationPolicyProvider policyProvider = null) + { + requestDelegate = requestDelegate ?? ((context) => Task.CompletedTask); + + return new AuthorizationMiddleware(requestDelegate, policyProvider); + } + + private Endpoint CreateEndpoint(params object[] metadata) + { + return new Endpoint(context => Task.CompletedTask, new EndpointMetadataCollection(metadata), "Test endpoint"); + } + + private HttpContext GetHttpContext( + bool anonymous = false, + Action registerServices = null, + Endpoint endpoint = null, + IAuthenticationService authenticationService = null) + { + var basicPrincipal = new ClaimsPrincipal( + new ClaimsIdentity( + new Claim[] { + new Claim("Permission", "CanViewPage"), + new Claim(ClaimTypes.Role, "Administrator"), + new Claim(ClaimTypes.Role, "User"), + new Claim(ClaimTypes.NameIdentifier, "John")}, + "Basic")); + + var validUser = basicPrincipal; + + var bearerIdentity = new ClaimsIdentity( + new Claim[] { + new Claim("Permission", "CupBearer"), + new Claim(ClaimTypes.Role, "Token"), + new Claim(ClaimTypes.NameIdentifier, "John Bear")}, + "Bearer"); + + validUser.AddIdentity(bearerIdentity); + + // ServiceProvider + var serviceCollection = new ServiceCollection(); + + authenticationService = authenticationService ?? Mock.Of(); + + serviceCollection.AddSingleton(authenticationService); + serviceCollection.AddOptions(); + serviceCollection.AddLogging(); + serviceCollection.AddAuthorization(); + serviceCollection.AddAuthorizationPolicyEvaluator(); + registerServices?.Invoke(serviceCollection); + + var serviceProvider = serviceCollection.BuildServiceProvider(); + + //// HttpContext + var httpContext = new DefaultHttpContext(); + if (endpoint != null) + { + httpContext.SetEndpoint(endpoint); + } + httpContext.RequestServices = serviceProvider; + if (!anonymous) + { + httpContext.User = validUser; + } + + return httpContext; + } + + private class TestRequestDelegate + { + private readonly int _statusCode; + + public bool Called => CalledCount > 0; + public int CalledCount { get; private set; } + + public TestRequestDelegate(int statusCode = 200) + { + _statusCode = statusCode; + } + + public Task Invoke(HttpContext context) + { + CalledCount++; + context.Response.StatusCode = _statusCode; + return Task.CompletedTask; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index ef17b9462..230e95c4c 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1025,6 +1025,11 @@ public Task GetDefaultPolicyAsync() return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); } + public Task GetRequiredPolicyAsync() + { + return Task.FromResult(null); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); @@ -1059,6 +1064,11 @@ public Task GetDefaultPolicyAsync() return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); } + public Task GetRequiredPolicyAsync() + { + return Task.FromResult(null); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireClaim(policyName).Build()); 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 d4379c3aa..40a8fff12 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -2,6 +2,7 @@ $(StandardTestTfms) + $(NoWarn);NU1605 @@ -11,8 +12,10 @@ + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs b/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs new file mode 100644 index 000000000..0c17693d1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.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 System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authorization.Test.TestObjects +{ + public class TestAuthenticationService : IAuthenticationService + { + public bool ChallengeCalled => ChallengeCount > 0; + public bool ForbidCalled => ForbidCount > 0; + public bool AuthenticateCalled => AuthenticateCount > 0; + + public int ChallengeCount { get; private set; } + public int ForbidCount { get; private set; } + public int AuthenticateCount { get; private set; } + + public Task AuthenticateAsync(HttpContext context, string scheme) + { + AuthenticateCount++; + + var identity = context.User.Identities.SingleOrDefault(i => i.AuthenticationType == scheme); + if (identity != null) + { + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(identity), scheme))); + } + + return Task.FromResult(AuthenticateResult.Fail("Denied")); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file From 42dd66647dd389c242ff796a530b880c7b9d7a90 Mon Sep 17 00:00:00 2001 From: Ben McCallum Date: Tue, 13 Nov 2018 23:05:55 +0100 Subject: [PATCH 607/611] refactor: Rename param from requiredValues to allowedValues to better indicate usage. (#1908) --- .../AuthorizationPolicyBuilder.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 37335df8f..ddca49d3a 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -96,16 +96,16 @@ public AuthorizationPolicyBuilder Combine(AuthorizationPolicy policy) /// to the current instance. /// /// The claim type required. - /// Values the claim must process one or more of for evaluation to succeed. + /// 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) + public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] allowedValues) { if (claimType == null) { throw new ArgumentNullException(nameof(claimType)); } - return RequireClaim(claimType, (IEnumerable)requiredValues); + return RequireClaim(claimType, (IEnumerable)allowedValues); } /// @@ -113,16 +113,16 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] /// to the current instance. /// /// The claim type required. - /// Values the claim must process one or more of for evaluation to succeed. + /// 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) + public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable allowedValues) { if (claimType == null) { throw new ArgumentNullException(nameof(claimType)); } - Requirements.Add(new ClaimsAuthorizationRequirement(claimType, requiredValues)); + Requirements.Add(new ClaimsAuthorizationRequirement(claimType, allowedValues)); return this; } From 7e14b052ea9cb935ec4f5cb0485b4edb5d41297a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Fri, 16 Nov 2018 00:12:42 +0100 Subject: [PATCH 608/611] Add AccessDeniedPath support to the OIDC/OAuth2/Twitter providers (#1887) * Add AccessDeniedPath support to the OIDC/OAuth2/Twitter providers * Update the code documentation and remove an unnecessary call to SignOutAsync() * Introduce a new AccessDenied event and move most of the access denied handling logic to RemoteAuthenticationHandler * Add ReturnUrlParameter support to RemoteAuthenticationHandler * Remove AccessDeniedException and introduce RemoteAuthenticationHandler.HandleAccessDeniedErrorAsync() * Use OriginalPath instead of Request.Path * Update obsolete code comments * Add unit tests for the new AccessDenied event * Allow customizing the access denied path/return URL/return URL parameter from the AccessDenied event --- samples/OpenIdConnectSample/Startup.cs | 11 ++ .../CookieAuthenticationHandler.cs | 4 +- .../OAuthHandler.cs | 12 +- .../OAuthOptions.cs | 6 +- .../OpenIdConnectHandler.cs | 14 ++- .../TwitterHandler.cs | 10 +- .../TwitterOptions.cs | 2 +- .../WsFederationHandler.cs | 2 +- .../Events/AccessDeniedContext.cs | 44 ++++++++ .../Events/RemoteAuthenticationEvents.cs | 8 +- .../LoggingExtensions.cs | 52 +++++++-- .../RemoteAuthenticationHandler.cs | 44 ++++++++ .../RemoteAuthenticationOptions.cs | 16 +++ .../GoogleTests.cs | 68 +++++++++++- .../OAuthTests.cs | 103 +++++++++++++++++- .../OpenIdConnect/OpenIdConnectEventTests.cs | 60 +++++++++- .../TwitterTests.cs | 90 ++++++++++++++- 17 files changed, 510 insertions(+), 36 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 1aa7625cb..a2b5a9a5c 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -63,6 +63,7 @@ public void ConfigureServices(IServiceCollection services) o.ResponseType = OpenIdConnectResponseType.CodeIdToken; o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; + o.AccessDeniedPath = "/access-denied-from-remote"; o.ClaimActions.MapAllExcept("aud", "iss", "iat", "nbf", "exp", "aio", "c_hash", "uti", "nonce"); @@ -126,6 +127,16 @@ await WriteHtmlAsync(response, async res => return; } + if (context.Request.Path.Equals("/access-denied-from-remote")) + { + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"

Access Denied error received from the remote authorization server

"); + await res.WriteAsync("Home"); + }); + return; + } + if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index b77a51ef4..ff6bb3cbc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -422,7 +422,7 @@ protected override async Task HandleForbiddenAsync(AuthenticationProperties prop var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { - returnUrl = OriginalPathBase + Request.Path + Request.QueryString; + returnUrl = OriginalPathBase + OriginalPath + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(accessDeniedUri)); @@ -434,7 +434,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { - redirectUri = OriginalPathBase + Request.Path + Request.QueryString; + redirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 808e0f903..05ba4df68 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -63,6 +63,16 @@ protected override async Task HandleRemoteAuthenticateAsync var error = query["error"]; if (!StringValues.IsNullOrEmpty(error)) { + // Note: access_denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + // Visit https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for more information. + if (StringValues.Equals(error, "access_denied")) + { + return await HandleAccessDeniedErrorAsync(properties); + } + var failureMessage = new StringBuilder(); failureMessage.Append(error); var errorDescription = query["error_description"]; @@ -194,7 +204,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop { if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } // OAuth2 10.12 CSRF diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 3c71f055f..4eacbd0b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -3,11 +3,9 @@ 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; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.OAuth { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 029cf541b..8b0b72428 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -186,7 +186,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) properties.RedirectUri = BuildRedirectUriIfRelative(Options.SignedOutRedirectUri); if (string.IsNullOrWhiteSpace(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } } Logger.PostSignOutRedirect(properties.RedirectUri); @@ -312,7 +312,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // 2. CurrentUri if RedirectUri is not set) if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } Logger.PostAuthenticationLocalRedirect(properties.RedirectUri); @@ -520,6 +520,16 @@ protected override async Task HandleRemoteAuthenticateAsync // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { + // Note: access_denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + // Visit https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for more information. + if (string.Equals(authorizationResponse.Error, "access_denied", StringComparison.Ordinal)) + { + return await HandleAccessDeniedErrorAsync(properties); + } + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null), properties); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 51dabbd99..cc8591ed3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -55,12 +55,14 @@ protected override async Task HandleRemoteAuthenticateAsync var properties = requestToken.Properties; - // REVIEW: see which of these are really errors - var denied = query["denied"]; if (!StringValues.IsNullOrEmpty(denied)) { - return HandleRequestResult.Fail("The user denied permissions.", properties); + // Note: denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + return await HandleAccessDeniedErrorAsync(properties); } var returnedToken = query["oauth_token"]; @@ -130,7 +132,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop { if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } // If CallbackConfirmed is false, this will throw diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 03396807e..269516ae1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.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 System.Security.Claims; using System.Globalization; +using System.Security.Claims; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs index e47f8431f..c4bb8fff7 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs @@ -83,7 +83,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // Save the original challenge URI so we can redirect back to it when we're done. if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } var wsFederationMessage = new WsFederationMessage() diff --git a/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs new file mode 100644 index 000000000..f01d69453 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.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; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Provides access denied failure context information to handler providers. + /// + public class AccessDeniedContext : HandleRequestContext + { + public AccessDeniedContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options) + : base(context, scheme, options) + { + } + + /// + /// Gets or sets the endpoint path the user agent will be redirected to. + /// By default, this property is set to . + /// + public PathString AccessDeniedPath { get; set; } + + /// + /// Additional state values for the authentication session. + /// + public AuthenticationProperties Properties { get; set; } + + /// + /// Gets or sets the return URL that will be flowed up to the access denied page. + /// If is not set, this property is not used. + /// + public string ReturnUrl { get; set; } + + /// + /// Gets or sets the parameter name that will be used to flow the return URL. + /// By default, this property is set to . + /// + public string ReturnUrlParameter { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index ca0f4a5c0..be4c6ab49 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -8,12 +8,18 @@ namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { + public Func OnAccessDenied { 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 + /// Invoked when an access denied error was returned by the remote server. + /// + public virtual Task AccessDenied(AccessDeniedContext context) => OnAccessDenied(context); + + /// + /// Invoked when there is a remote failure. /// public virtual Task RemoteFailure(RemoteFailureContext context) => OnRemoteFailure(context); diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 8cba6c0d5..042bfabca 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -7,17 +7,20 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _authSchemeAuthenticated; - private static Action _authSchemeNotAuthenticated; - private static Action _authSchemeNotAuthenticatedWithFailure; - private static Action _authSchemeChallenged; - private static Action _authSchemeForbidden; - private static Action _remoteAuthenticationError; - private static Action _signInHandled; - private static Action _signInSkipped; - private static Action _correlationPropertyNotFound; - private static Action _correlationCookieNotFound; - private static Action _unexpectedCorrelationCookieValue; + private static readonly Action _authSchemeAuthenticated; + private static readonly Action _authSchemeNotAuthenticated; + private static readonly Action _authSchemeNotAuthenticatedWithFailure; + private static readonly Action _authSchemeChallenged; + private static readonly Action _authSchemeForbidden; + private static readonly Action _remoteAuthenticationError; + private static readonly Action _signInHandled; + private static readonly Action _signInSkipped; + private static readonly Action _correlationPropertyNotFound; + private static readonly Action _correlationCookieNotFound; + private static readonly Action _unexpectedCorrelationCookieValue; + private static readonly Action _accessDeniedError; + private static readonly Action _accessDeniedContextHandled; + private static readonly Action _accessDeniedContextSkipped; static LoggingExtensions() { @@ -65,6 +68,18 @@ static LoggingExtensions() eventId: 16, logLevel: LogLevel.Warning, formatString: "The correlation cookie value '{CorrelationCookieName}' did not match the expected value '{CorrelationCookieValue}'."); + _accessDeniedError = LoggerMessage.Define( + eventId: 17, + logLevel: LogLevel.Information, + formatString: "Access was denied by the resource owner or by the remote server."); + _accessDeniedContextHandled = LoggerMessage.Define( + eventId: 18, + logLevel: LogLevel.Debug, + formatString: "The AccessDenied event returned Handled."); + _accessDeniedContextSkipped = LoggerMessage.Define( + eventId: 19, + logLevel: LogLevel.Debug, + formatString: "The AccessDenied event returned Skipped."); } public static void AuthenticationSchemeAuthenticated(this ILogger logger, string authenticationScheme) @@ -121,5 +136,20 @@ public static void UnexpectedCorrelationCookieValue(this ILogger logger, string { _unexpectedCorrelationCookieValue(logger, cookieName, cookieValue, null); } + + public static void AccessDeniedError(this ILogger logger) + { + _accessDeniedError(logger, null); + } + + public static void AccessDeniedContextHandled(this ILogger logger) + { + _accessDeniedContextHandled(logger, null); + } + + public static void AccessDeniedContextSkipped(this ILogger logger) + { + _accessDeniedContextSkipped(logger, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bea4895d6..c72583b5c 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -241,5 +242,48 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties return true; } + + protected virtual async Task HandleAccessDeniedErrorAsync(AuthenticationProperties properties) + { + Logger.AccessDeniedError(); + var context = new AccessDeniedContext(Context, Scheme, Options) + { + AccessDeniedPath = Options.AccessDeniedPath, + Properties = properties, + ReturnUrl = properties?.RedirectUri, + ReturnUrlParameter = Options.ReturnUrlParameter + }; + await Events.AccessDenied(context); + + if (context.Result != null) + { + if (context.Result.Handled) + { + Logger.AccessDeniedContextHandled(); + } + else if (context.Result.Skipped) + { + Logger.AccessDeniedContextSkipped(); + } + + return context.Result; + } + + // If an access denied endpoint was specified, redirect the user agent. + // Otherwise, invoke the RemoteFailure event for further processing. + if (context.AccessDeniedPath.HasValue) + { + string uri = context.AccessDeniedPath; + if (!string.IsNullOrEmpty(context.ReturnUrlParameter) && !string.IsNullOrEmpty(context.ReturnUrl)) + { + uri = QueryHelpers.AddQueryString(uri, context.ReturnUrlParameter, context.ReturnUrl); + } + Response.Redirect(uri); + + return HandleRequestResult.Handle(); + } + + return HandleRequestResult.Fail("Access was denied by the resource owner or by the remote server.", properties); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 1bd3b210e..188b7a991 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -89,6 +89,22 @@ public override void Validate() /// public PathString CallbackPath { get; set; } + /// + /// Gets or sets the optional path the user agent is redirected to if the user + /// doesn't approve the authorization demand requested by the remote server. + /// This property is not set by default. In this case, an exception is thrown + /// if an access_denied response is returned by the remote authorization server. + /// + public PathString AccessDeniedPath { get; set; } + + /// + /// Gets or sets the name of the parameter used to convey the original location + /// of the user before the remote challenge was triggered up to the access denied page. + /// This property is only used when the is explicitly specified. + /// + // Note: this deliberately matches the default parameter name used by the cookie handler. + public string ReturnUrlParameter { get; set; } = "ReturnUrl"; + /// /// Gets or sets the authentication scheme corresponding to the middleware /// responsible of persisting user's identity after a successful authentication. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 19d7d898b..ce158eaf2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -357,6 +357,70 @@ public async Task ReplyPathWithoutStateQueryStringWillBeRejected() Assert.Equal("The oauth state was missing or invalid.", error.GetBaseException().Message); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ReplyPathWithAccessDeniedErrorFails(bool redirect) + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); + o.Events = redirect ? new OAuthEvents() + { + OnAccessDenied = ctx => + { + ctx.Response.Redirect("/error?FailureMessage=AccessDenied"); + ctx.HandleResponse(); + return Task.FromResult(0); + } + } : new OAuthEvents(); + }); + var sendTask = server.SendAsync("https://example.com/signin-google?error=access_denied&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.correlationId=N"); + if (redirect) + { + var transaction = await sendTask; + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/error?FailureMessage=AccessDenied", transaction.Response.Headers.GetValues("Location").First()); + } + else + { + var error = await Assert.ThrowsAnyAsync(() => sendTask); + Assert.Equal("Access was denied by the resource owner or by the remote server.", error.GetBaseException().Message); + } + } + + [Fact] + public async Task ReplyPathWithAccessDeniedError_AllowsCustomizingPath() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); + o.AccessDeniedPath = "/access-denied"; + o.Events = new OAuthEvents() + { + OnAccessDenied = ctx => + { + Assert.Equal("/access-denied", ctx.AccessDeniedPath.Value); + Assert.Equal("http://testhost/redirect", ctx.ReturnUrl); + Assert.Equal("ReturnUrl", ctx.ReturnUrlParameter); + ctx.AccessDeniedPath = "/custom-denied-page"; + ctx.ReturnUrl = "http://www.google.com/"; + ctx.ReturnUrlParameter = "rurl"; + return Task.FromResult(0); + } + }; + }); + var transaction = await server.SendAsync("https://example.com/signin-google?error=access_denied&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.correlationId=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/custom-denied-page?rurl=http%3A%2F%2Fwww.google.com%2F", transaction.Response.Headers.GetValues("Location").First()); + } + [Theory] [InlineData(true)] [InlineData(false)] @@ -378,7 +442,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) } : new OAuthEvents(); }); 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"); + ".AspNetCore.Correlation.Google.correlationId=N"); if (redirect) { var transaction = await sendTask; @@ -1205,7 +1269,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 87131b8d7..838798cea 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -251,6 +251,101 @@ protected override void ConfigureDefaults(OAuthOptions o) o.CallbackPath = "/oauth-callback"; } + [Fact] + public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySet() + { + 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.AccessDeniedPath = "/access-denied"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events.OnRemoteFailure = context => throw new InvalidOperationException("This event should not be called."); + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/access-denied?ReturnUrl=http%3A%2F%2Ftesthost%2Fredirect", transaction.Response.Headers.Location.ToString()); + } + + [Fact] + public async Task HandleRequestAsync_InvokesAccessDeniedEvent() + { + 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() + { + OnAccessDenied = context => + { + 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=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + + [Fact] + public async Task HandleRequestAsync_InvokesRemoteFailureEventWhenAccessDeniedPathIsNotExplicitlySet() + { + 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.Equal("Access was denied by the resource owner or by the remote server.", 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=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + [Fact] public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { @@ -270,7 +365,7 @@ public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { OnRemoteFailure = context => { - Assert.Contains("declined", context.Failure.Message); + Assert.Contains("custom_error", context.Failure.Message); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; context.HandleResponse(); @@ -279,8 +374,8 @@ public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() }; })); - var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=declined&state=protected_state", - ".AspNetCore.Correlation.Weblie.corrilationId=N"); + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=custom_error&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); Assert.Null(transaction.Response.Headers.Location); @@ -323,7 +418,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 7530b00c3..090bf3dec 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -783,6 +783,52 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( events.ValidateExpectations(); } + [Fact] + public async Task OnAccessDenied_Skip_NoMoreEventsRun() + { + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectAccessDenied = true + }; + events.OnAccessDenied = context => + { + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); + + var response = await PostAsync(server, "signin-oidc", "error=access_denied&state=protected_state"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + events.ValidateExpectations(); + } + + [Fact] + public async Task OnAccessDenied_Handled_NoMoreEventsRun() + { + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectAccessDenied = true + }; + events.OnAccessDenied = context => + { + 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", "error=access_denied&state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + events.ValidateExpectations(); + } + [Fact] public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { @@ -1099,6 +1145,9 @@ private class ExpectedOidcEvents : OpenIdConnectEvents public bool ExpectTokenValidated { get; set; } public bool InvokedTokenValidated { get; set; } + public bool ExpectAccessDenied { get; set; } + public bool InvokedAccessDenied { get; set; } + public bool ExpectRemoteFailure { get; set; } public bool InvokedRemoteFailure { get; set; } @@ -1168,6 +1217,12 @@ public override Task TicketReceived(TicketReceivedContext context) return base.TicketReceived(context); } + public override Task AccessDenied(AccessDeniedContext context) + { + InvokedAccessDenied = true; + return base.AccessDenied(context); + } + public override Task RemoteFailure(RemoteFailureContext context) { InvokedRemoteFailure = true; @@ -1201,6 +1256,7 @@ public void ValidateExpectations() Assert.Equal(ExpectUserInfoReceived, InvokedUserInfoReceived); Assert.Equal(ExpectAuthenticationFailed, InvokeAuthenticationFailed); Assert.Equal(ExpectTicketReceived, InvokedTicketReceived); + Assert.Equal(ExpectAccessDenied, InvokedAccessDenied); Assert.Equal(ExpectRemoteFailure, InvokedRemoteFailure); Assert.Equal(ExpectRedirectForSignOut, InvokedRedirectForSignOut); Assert.Equal(ExpectRemoteSignOut, InvokedRemoteSignOut); @@ -1248,7 +1304,7 @@ private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appC private Task PostAsync(TestServer server, string path, string form) { var client = server.CreateClient(); - var cookie = ".AspNetCore.Correlation." + OpenIdConnectDefaults.AuthenticationScheme + ".corrilationId=N"; + var cookie = ".AspNetCore.Correlation." + OpenIdConnectDefaults.AuthenticationScheme + ".correlationId=N"; client.DefaultRequestHeaders.Add("Cookie", cookie); return client.PostAsync("signin-oidc", new StringContent(form, Encoding.ASCII, "application/x-www-form-urlencoded")); @@ -1273,7 +1329,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" }, { "testkey", "testvalue" } }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index c438b1f3f..8eb7a5cd7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -174,6 +174,94 @@ public async Task ChallengeWillTriggerRedirection() Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); } + [Fact] + public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySet() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.AccessDeniedPath = "/access-denied"; + o.Events.OnRemoteFailure = context => throw new InvalidOperationException("This event should not be called."); + }, + 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?denied=ABCDEFG"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); + Assert.Equal("/access-denied?ReturnUrl=%2Fchallenge", response.Headers.Location.ToString()); + } + + [Fact] + public async Task BadCallbackCallsAccessDeniedWithState() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.Events = new TwitterEvents() + { + OnAccessDenied = context => + { + 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?denied=ABCDEFG"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.NotAcceptable, response.StatusCode); + } + [Fact] public async Task BadCallbackCallsRemoteAuthFailedWithState() { @@ -190,7 +278,7 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() OnRemoteFailure = context => { Assert.NotNull(context.Failure); - Assert.Equal("The user denied permissions.", context.Failure.Message); + Assert.Equal("Access was denied by the resource owner or by the remote server.", context.Failure.Message); Assert.NotNull(context.Properties); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; From d1ee5a22fbda54fc2352d937d7064b451a95b72a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 16 Nov 2018 14:25:30 -0800 Subject: [PATCH 609/611] Remove obsolete apis (#1915) --- .../CookieAuthenticationOptions.cs | 63 ------------------- .../breakingchanges.netcore.json | 52 +++++++++++++++ .../JwtBearerHandler.cs | 2 +- .../breakingchanges.netcore.json | 7 +++ ...thenticationServiceCollectionExtensions.cs | 42 ------------- .../breakingchanges.netcore.json | 22 +++++++ .../AuthorizeAttribute.cs | 10 --- 7 files changed, 82 insertions(+), 116 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 35017f9c4..78156caec 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -147,68 +147,5 @@ public CookieBuilder Cookie /// /// public TimeSpan ExpireTimeSpan { 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.Name) + ".")] - 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.HttpOnly) + ".")] - 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; } - #endregion } } 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 000000000..7a1ab7962 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,52 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public Microsoft.AspNetCore.Http.CookieSecurePolicy get_CookieSecure()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Boolean get_CookieHttpOnly()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookieDomain()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookieName()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookiePath()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieDomain(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieHttpOnly(System.Boolean value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieName(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookiePath(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieSecure(Microsoft.AspNetCore.Http.CookieSecurePolicy value)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 452d9639f..4f03ccd69 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -22,7 +22,7 @@ public class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; - public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } 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 000000000..d17003a80 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -0,0 +1,7 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptionsMonitor options, Microsoft.Extensions.Logging.ILoggerFactory logger, System.Text.Encodings.Web.UrlEncoder encoder, Microsoft.AspNetCore.DataProtection.IDataProtectionProvider dataProtection, Microsoft.AspNetCore.Authentication.ISystemClock clock)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index b274eaace..6c381b84a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -46,48 +46,6 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se return builder; } - [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 - { - services.AddAuthentication(o => - { - o.AddScheme(authenticationScheme, scheme => { - scheme.HandlerType = typeof(THandler); - scheme.DisplayName = displayName; - configureScheme?.Invoke(scheme); - }); - }); - if (configureOptions != null) - { - services.Configure(authenticationScheme, configureOptions); - } - services.AddTransient(); - 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 - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); - return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); - } - // Used to ensure that there's always a sign in scheme private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json new file mode 100644 index 000000000..d5bc6954e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -0,0 +1,22 @@ + [ + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddRemoteScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions, new() where T1 : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureScheme, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index 63bfa30d4..b1f0f8bae 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -39,15 +39,5 @@ public AuthorizeAttribute(string policy) /// 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; - } } } From e0538784647990905f9c5fdc5bc2f0e5c7388909 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 19 Nov 2018 09:47:07 -0800 Subject: [PATCH 610/611] Upgrade packages and projects to target netcoreapp3.0 (aspnet/Security#1916) Changes: * Upgrade dependencies and build tools * Change TFM on Microsoft.AspNetCore.* packages to netcoreapp3.0 * Remove .NET Framework tests * Disable Owin interop tests. They need to be completely refactored --- Directory.Build.targets | 6 +- ...oft.AspNetCore.Security.Performance.csproj | 2 +- build/dependencies.props | 64 +++++++++---------- build/repo.props | 7 +- korebuild-lock.txt | 4 +- .../CookiePolicySample.csproj | 2 +- samples/CookieSample/CookieSample.csproj | 2 +- .../CookieSessionSample.csproj | 2 +- .../JwtBearerSample/JwtBearerSample.csproj | 2 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- .../OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- samples/WsFedSample/WsFedSample.csproj | 2 +- ...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 +- ...NetCore.Authentication.WsFederation.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 2 +- ...oft.AspNetCore.Authorization.Policy.csproj | 2 +- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- test/Directory.Build.props | 7 -- ...soft.AspNetCore.Authentication.Test.csproj | 2 +- ...osoft.AspNetCore.Authorization.Test.csproj | 2 +- ....ChunkingCookieManager.Sources.Test.csproj | 2 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 2 +- .../CookieInteropTests.cs | 5 ++ ...icrosoft.Owin.Security.Interop.Test.csproj | 3 +- .../TicketInteropTests.cs | 3 + 34 files changed, 71 insertions(+), 80 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 78626b773..7e3f8df92 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,10 +1,6 @@ - $(MicrosoftNETCoreApp20PackageVersion) - $(MicrosoftNETCoreApp21PackageVersion) - $(MicrosoftNETCoreApp22PackageVersion) + $(MicrosoftNETCoreAppPackageVersion) $(NETStandardLibrary20PackageVersion) - - 99.9 diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj index 7226b64be..2f16dd669 100644 --- a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.0 Exe true true diff --git a/build/dependencies.props b/build/dependencies.props index 230a942c0..163a3d400 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,42 +4,40 @@ 0.10.13 - 3.0.0-alpha1-20181004.7 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10657 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-a-alpha1-endpoint-extensions-namespace-16778 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 + 3.0.0-build-20181114.5 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-preview-181113-11 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 3.19.8 5.3.0 5.3.0 - 2.0.9 - 2.1.3 - 2.2.0-rtm-27105-02 + 3.0.0-preview1-26907-05 15.6.1 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 6fc6af601..4402da1d0 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,9 +1,6 @@ - - - Internal.AspNetCore.Universe.Lineup @@ -11,8 +8,6 @@ - - - + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 591cfd52f..73613543d 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20181004.7 -commithash:27fabdaf2b1d4753c3d2749581694ca65d78f7f2 +version:3.0.0-build-20181114.5 +commithash:880e9a204d4ee4a18dfd83c9fb05a192a28bca60 diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj index 48227eb07..010edb018 100644 --- a/samples/CookiePolicySample/CookiePolicySample.csproj +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 1029f1819..bc92d68a2 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 19bd04374..6230c98a5 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 3e0192a23..58bf5e2d9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 2abd57cd8..61754b60b 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index bb02ef159..137ee47ba 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a08b9799d..e1e2262b0 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-SocialSample-20151210111056 diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj index 4fb38fa3e..e1191ac81 100644 --- a/samples/WsFedSample/WsFedSample.csproj +++ b/samples/WsFedSample/WsFedSample.csproj @@ -1,7 +1,7 @@ - net461 + netcoreapp3.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 b188a58e0..093f60a3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netstandard2.0 + netcoreapp3.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 62aee1367..f57fe26e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netstandard2.0 + netcoreapp3.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 de8867f91..eba5b98ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -2,7 +2,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netstandard2.0 + netcoreapp3.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 e5bae5a3d..8a26c58f3 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. - netstandard2.0 + netcoreapp3.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 0eddc6f76..1841157c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netstandard2.0 + netcoreapp3.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 5c8a5e3a9..97d4a9703 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netstandard2.0 + netcoreapp3.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 b7f4c1704..65ca6b842 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. - netstandard2.0 + netcoreapp3.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 f720d08f0..4f2aae616 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj index 4edb55cb3..ae4d52aff 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the WsFederation authentication workflow. - netstandard2.0 + netcoreapp3.0 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 7e3ce4eb3..9ae0a7bcc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -2,7 +2,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security 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 aba88dd50..d3ad99a51 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -2,7 +2,7 @@ ASP.NET Core authorization policy helper classes. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591;NU1605 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index ac4aa6c32..9192ac8cf 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -5,7 +5,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netstandard2.0 + netcoreapp3.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 40f97633a..81760d50a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -2,7 +2,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore diff --git a/test/Directory.Build.props b/test/Directory.Build.props index e3d2d9f14..c42d54465 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,13 +1,6 @@ - - netcoreapp2.2 - $(DeveloperBuildTestTfms) - $(StandardTestTfms) - $(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 6c8d518ff..c7a380868 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,7 @@  - $(StandardTestTfms) + netcoreapp3.0 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 40a8fff12..9ff42a070 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,7 @@  - $(StandardTestTfms) + netcoreapp3.0 $(NoWarn);NU1605 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 20cd400ce..2f38abff9 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,7 @@  - $(StandardTestTfms) + netcoreapp3.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 d7a42f3ef..3dc3df2e2 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp3.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index e2e4fd7d0..24bf09722 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -1,6 +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. +/* See https://github.com/aspnet/AspNetCore/issues/4074. + +This test is was disabled as a part of changing frameworks. This test will need to be re-written using separate .NET Core and .NET Framework processes. + using System.Collections.Generic; using System.IO; using System.Linq; @@ -330,3 +334,4 @@ private class Transaction } } +*/ 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 f369f1f01..57b224ef6 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 @@ -2,10 +2,11 @@ net461 + + false - diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 769adc015..ccff1e936 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.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; using System.Linq; using System.Security.Claims; @@ -87,5 +89,6 @@ public void InteropSerializerCanReadNewTicket() } } } +*/ From 26d27d871b7992022c082dc207e3d126e1d9d278 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 21 Nov 2018 16:05:52 -0800 Subject: [PATCH 611/611] Update README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e8e64c293..66c2aa45e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -ASP.NET Security -======== +ASP.NET Security [Archived] +=========================== -AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/fujhh8n956v5ohfd/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/Security/branch/dev) - -Travis: [![Travis](https://travis-ci.org/aspnet/Security.svg?branch=dev)](https://travis-ci.org/aspnet/Security) +**This GitHub project has been archived.** Ongoing development on this project can be found in . Contains the security and authorization middlewares for ASP.NET Core. @@ -14,4 +12,4 @@ A list of community projects related to authentication and security for ASP.NET 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. +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [AspNetCore](https://github.com/aspnet/AspNetCore) repo.