Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 1850116

Browse files
committed
Added call to configuration before trying to delete the cookie
1 parent 94b1302 commit 1850116

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,13 @@ private string ReadNonceCookie(string nonce)
929929
var cookieOptions = new CookieOptions
930930
{
931931
HttpOnly = true,
932+
Path = OriginalPathBase + Options.CallbackPath,
932933
SameSite = Http.SameSiteMode.None,
933934
Secure = Request.IsHttps
934935
};
935936

937+
Options.ConfigureNonceCookie?.Invoke(Context, cookieOptions);
938+
936939
Response.Cookies.Delete(nonceKey, cookieOptions);
937940
return nonce;
938941
}

src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ protected override async Task<AuthenticateResult> HandleRemoteAuthenticateAsync(
8787
Secure = Request.IsHttps
8888
};
8989

90+
Options.ConfigureStateCookie?.Invoke(Context, cookieOptions);
91+
9092
Response.Cookies.Delete(StateCookie, cookieOptions);
9193

9294
var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier);
@@ -159,6 +161,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop
159161
Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout),
160162
};
161163

164+
Options.ConfigureStateCookie?.Invoke(Context, cookieOptions);
165+
162166
Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions);
163167

164168
var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint);

src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public TwitterOptions()
5858
/// </summary>
5959
public ISecureDataFormat<RequestToken> StateDataFormat { get; set; }
6060

61+
/// <summary>
62+
/// Gets or sets an action that can override the state cookie options before the
63+
/// cookie gets added to the response.
64+
/// </summary>
65+
public Action<HttpContext, CookieOptions> ConfigureStateCookie { get; set; }
66+
6167
/// <summary>
6268
/// Gets or sets the <see cref="TwitterEvents"/> used to handle authentication events.
6369
/// </summary>

src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,13 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties
246246
var cookieOptions = new CookieOptions
247247
{
248248
HttpOnly = true,
249+
Path = OriginalPathBase + Options.CallbackPath,
249250
SameSite = SameSiteMode.None,
250251
Secure = Request.IsHttps
251252
};
253+
254+
Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions);
255+
252256
Response.Cookies.Delete(cookieName, cookieOptions);
253257

254258
if (!string.Equals(correlationCookie, CorrelationMarker, StringComparison.Ordinal))

0 commit comments

Comments
 (0)