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

Commit ff80c71

Browse files
author
Nate McMaster
committed
fixup! Replace configure method on Twitter, RemoteAuthentication, and OpenIdConnect options with CookieBuilder
1 parent efc7cff commit ff80c71

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public CookieBuilder NonceCookie
282282
set => _nonceCookieBuilder = value ?? throw new ArgumentNullException(nameof(value));
283283
}
284284

285-
private class OpenIdConnectNonceCookieBuilder : PathScopingCookieBuilder
285+
private class OpenIdConnectNonceCookieBuilder : RequestPathCookieBuilder
286286
{
287287
private readonly OpenIdConnectOptions _options;
288288

@@ -291,7 +291,7 @@ public OpenIdConnectNonceCookieBuilder(OpenIdConnectOptions oidcOptions)
291291
_options = oidcOptions;
292292
}
293293

294-
protected override string PathScope => _options.CallbackPath;
294+
protected override string AdditionalPath => _options.CallbackPath;
295295

296296
public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom)
297297
{

src/Microsoft.AspNetCore.Authentication/Internal/PathScopingCookieBuilder.cs renamed to src/Microsoft.AspNetCore.Authentication/Internal/RequestPathCookieBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ namespace Microsoft.AspNetCore.Authentication.Internal
99
/// <summary>
1010
/// A cookie builder that set <see cref="CookieOptions.Path"/> to the original path base plus some scope.
1111
/// </summary>
12-
public abstract class PathScopingCookieBuilder : CookieBuilder
12+
public class RequestPathCookieBuilder : CookieBuilder
1313
{
1414
/// <summary>
15-
/// Path that is appended to the request path base.
15+
/// Optional additional path that is appended to the request path base.
1616
/// </summary>
17-
protected abstract string PathScope { get; }
17+
protected virtual string AdditionalPath { get; }
1818

1919
public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom)
2020
{
@@ -23,7 +23,7 @@ public override CookieOptions Build(HttpContext context, DateTimeOffset expiresF
2323
if (path == null)
2424
{
2525
var originalPathBase = context.Features.Get<IAuthenticationFeature>()?.OriginalPathBase ?? context.Request.PathBase;
26-
path = originalPathBase + PathScope;
26+
path = originalPathBase + AdditionalPath;
2727
}
2828

2929
var options = base.Build(context, expiresFrom);

src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,24 @@ public CookieBuilder CorrelationIdCookie
112112
set => _correlationIdCookieBuilder = value ?? throw new ArgumentNullException(nameof(value));
113113
}
114114

115-
private class CorrelationIdCookieBuilder : PathScopingCookieBuilder
115+
private class CorrelationIdCookieBuilder : RequestPathCookieBuilder
116116
{
117-
private readonly RemoteAuthenticationOptions _optoins;
117+
private readonly RemoteAuthenticationOptions _options;
118118

119119
public CorrelationIdCookieBuilder(RemoteAuthenticationOptions remoteAuthenticationOptions)
120120
{
121-
_optoins = remoteAuthenticationOptions;
121+
_options = remoteAuthenticationOptions;
122122
}
123123

124-
protected override string PathScope => _optoins.CallbackPath;
124+
protected override string AdditionalPath => _options.CallbackPath;
125125

126126
public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom)
127127
{
128128
var cookieOptions = base.Build(context, expiresFrom);
129129

130130
if (!Expiration.HasValue || !cookieOptions.Expires.HasValue)
131131
{
132-
cookieOptions.Expires = expiresFrom.Add(_optoins.RemoteAuthenticationTimeout);
132+
cookieOptions.Expires = expiresFrom.Add(_options.RemoteAuthenticationTimeout);
133133
}
134134

135135
return cookieOptions;

0 commit comments

Comments
 (0)