From 0a8c81b7f9aa1b3f0e1c133a37e8d56da73cb4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Fri, 27 Aug 2021 13:26:04 +0200 Subject: [PATCH] Bump OpenIddict to 3.1.1 --- Packages.props | 14 +++++++------- .../Controllers/AuthorizationController.cs | 9 ++------- .../Controllers/AuthorizationController.cs | 9 ++------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Packages.props b/Packages.props index 32d434b51..68ad28f6a 100644 --- a/Packages.props +++ b/Packages.props @@ -27,13 +27,13 @@ - - - - - - - + + + + + + + diff --git a/samples/Balosar/Balosar.Server/Controllers/AuthorizationController.cs b/samples/Balosar/Balosar.Server/Controllers/AuthorizationController.cs index c5a412b18..d40e8e9be 100644 --- a/samples/Balosar/Balosar.Server/Controllers/AuthorizationController.cs +++ b/samples/Balosar/Balosar.Server/Controllers/AuthorizationController.cs @@ -75,7 +75,8 @@ public async Task 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. @@ -336,12 +337,6 @@ public async Task 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 GetDestinations(Claim claim, ClaimsPrincipal principal) { // Note: by default, claims are NOT automatically included in the access and identity tokens. diff --git a/samples/Velusia/Velusia.Server/Controllers/AuthorizationController.cs b/samples/Velusia/Velusia.Server/Controllers/AuthorizationController.cs index 13444fca1..5b256ab0c 100644 --- a/samples/Velusia/Velusia.Server/Controllers/AuthorizationController.cs +++ b/samples/Velusia/Velusia.Server/Controllers/AuthorizationController.cs @@ -81,7 +81,8 @@ public async Task 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. @@ -341,12 +342,6 @@ public async Task 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 GetDestinations(Claim claim, ClaimsPrincipal principal) { // Note: by default, claims are NOT automatically included in the access and identity tokens.