diff --git a/Core/Http/HttpClientAdapter.cs b/Core/Http/HttpClientAdapter.cs index 39b9c85..8a0905f 100644 --- a/Core/Http/HttpClientAdapter.cs +++ b/Core/Http/HttpClientAdapter.cs @@ -137,19 +137,23 @@ private async Task ExecuteHttpMethod(Func LoginAsync(LoginRequestDto request, Dictiona } catch (Exception ex) { + Log.Logger.Error(ex, "IDP LoginAsync failed"); return LoginResponseDto.Failed(ex.Message); } } @@ -81,6 +83,7 @@ public async Task IdentityAsync(IdentityRequestDto request, } catch (Exception ex) { + Log.Logger.Error(ex, "IDP IdentityAsync failed"); return IdentityResponseDto.Failed(ex.Message); } } diff --git a/MultiFactor.SelfService.Windows.Portal.csproj b/MultiFactor.SelfService.Windows.Portal.csproj index ba310ad..4401db1 100644 --- a/MultiFactor.SelfService.Windows.Portal.csproj +++ b/MultiFactor.SelfService.Windows.Portal.csproj @@ -642,6 +642,7 @@ + diff --git a/Services/TokenValidationService.cs b/Services/TokenValidationService.cs index dc83ae8..29f7528 100644 --- a/Services/TokenValidationService.cs +++ b/Services/TokenValidationService.cs @@ -4,6 +4,7 @@ using MultiFactor.SelfService.Windows.Portal.Services.API; using Serilog; using System; +using System.Globalization; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net; @@ -81,7 +82,14 @@ public bool VerifyToken(string jwt, out Token token) claim.Type == MultiFactorClaims.PasswordExpirationDate); if (_configuration.NotifyOnPasswordExpirationDaysLeft > 0 && passwordExpirationDate?.Value != null) { - token.PasswordExpirationDate = DateTime.Parse(passwordExpirationDate.Value); + if (DateTime.TryParse(passwordExpirationDate.Value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var parsed)) + { + token.PasswordExpirationDate = parsed; + } + else + { + _logger.Warning("Failed to parse passwordExpirationDate claim value '{Value}'", passwordExpirationDate.Value); + } } return true; //token valid diff --git a/Stories/SignIn/ClaimsSources/MultiFactorClaimsSource.cs b/Stories/SignIn/ClaimsSources/MultiFactorClaimsSource.cs index c859e9a..ff9cd99 100644 --- a/Stories/SignIn/ClaimsSources/MultiFactorClaimsSource.cs +++ b/Stories/SignIn/ClaimsSources/MultiFactorClaimsSource.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Globalization; using MultiFactor.SelfService.Windows.Portal.Core.Authentication.AuthenticationClaims; @@ -30,8 +31,13 @@ public IReadOnlyDictionary GetClaims() return claims; } - claims.Add(MultiFactorClaims.PasswordExpirationDate, - result.PasswordExpirationDate.ToString(CultureInfo.InvariantCulture)); + + if (result.PasswordExpirationDate > DateTime.MinValue + && result.PasswordExpirationDate < DateTime.MaxValue) + { + claims.Add(MultiFactorClaims.PasswordExpirationDate, + result.PasswordExpirationDate.ToString(CultureInfo.InvariantCulture)); + } return claims; } diff --git a/Stories/SignIn/IdentityStory.cs b/Stories/SignIn/IdentityStory.cs index bc7dffd..40c22bf 100644 --- a/Stories/SignIn/IdentityStory.cs +++ b/Stories/SignIn/IdentityStory.cs @@ -92,6 +92,8 @@ public async Task ExecuteAsync(IdentityModel model, Dictionary ExecuteAsync(LoginModel model, Dictionary x.Key, x => x.Value); claims.Add(AuthenticationClaims.AUTHENTICATION_METHODS_REFERENCES, AuthenticationClaims.PASSWORD_METHOD);