Skip to content

Commit

Permalink
Bump OpenIddict to 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Aug 27, 2021
1 parent d1b521e commit 0a8c81b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
14 changes: 7 additions & 7 deletions Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<PackageReference Update="Microsoft.Owin.Host.HttpListener" Version="4.2.0" />
<PackageReference Update="Microsoft.Owin.Hosting" Version="4.2.0" />
<PackageReference Update="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Update="OpenIddict.AspNetCore" Version="3.1.0" />
<PackageReference Update="OpenIddict.Abstractions" Version="3.1.0" />
<PackageReference Update="OpenIddict.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Update="OpenIddict.Owin" Version="3.1.0" />
<PackageReference Update="OpenIddict.Quartz" Version="3.1.0" />
<PackageReference Update="OpenIddict.Validation.AspNetCore" Version="3.1.0" />
<PackageReference Update="OpenIddict.Validation.SystemNetHttp" Version="3.1.0" />
<PackageReference Update="OpenIddict.AspNetCore" Version="3.1.1" />
<PackageReference Update="OpenIddict.Abstractions" Version="3.1.1" />
<PackageReference Update="OpenIddict.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Update="OpenIddict.Owin" Version="3.1.1" />
<PackageReference Update="OpenIddict.Quartz" Version="3.1.1" />
<PackageReference Update="OpenIddict.Validation.AspNetCore" Version="3.1.1" />
<PackageReference Update="OpenIddict.Validation.SystemNetHttp" Version="3.1.1" />
<PackageReference Update="Quartz.Extensions.Hosting" Version="3.2.4" />
<PackageReference Update="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public async Task<IActionResult> Authorize()
// If a max_age parameter was provided, ensure that the cookie is not too old.
// If the user principal can't be extracted or the cookie is too old, redirect the user to the login page.
var result = await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme);
if (result == null || !result.Succeeded || HasCookieExpired(request, result))
if (result == null || !result.Succeeded || (request.MaxAge != null && result.Properties?.IssuedUtc != null &&
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value)))
{
// If the client application requested promptless authentication,
// return an error indicating that the user is not logged in.
Expand Down Expand Up @@ -336,12 +337,6 @@ public async Task<IActionResult> Exchange()
throw new InvalidOperationException("The specified grant type is not supported.");
}

private bool HasCookieExpired(OpenIddictRequest request, AuthenticateResult result)
{
return request.MaxAge != null && result.Properties?.IssuedUtc != null &&
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value);
}

private IEnumerable<string> GetDestinations(Claim claim, ClaimsPrincipal principal)
{
// Note: by default, claims are NOT automatically included in the access and identity tokens.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public async Task<IActionResult> Authorize()
// If a max_age parameter was provided, ensure that the cookie is not too old.
// If the user principal can't be extracted or the cookie is too old, redirect the user to the login page.
var result = await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme);
if (result == null || !result.Succeeded || HasCookieExpired(request, result))
if (result == null || !result.Succeeded || (request.MaxAge != null && result.Properties?.IssuedUtc != null &&
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value)))
{
// If the client application requested promptless authentication,
// return an error indicating that the user is not logged in.
Expand Down Expand Up @@ -341,12 +342,6 @@ public async Task<IActionResult> Exchange()
throw new InvalidOperationException("The specified grant type is not supported.");
}

private bool HasCookieExpired(OpenIddictRequest request, AuthenticateResult result)
{
return request.MaxAge != null && result.Properties?.IssuedUtc != null &&
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value);
}

private IEnumerable<string> GetDestinations(Claim claim, ClaimsPrincipal principal)
{
// Note: by default, claims are NOT automatically included in the access and identity tokens.
Expand Down

0 comments on commit 0a8c81b

Please sign in to comment.