From 98a6738b882547371c5fdb4373cae5b9f4b01060 Mon Sep 17 00:00:00 2001 From: Matt Goldman Date: Wed, 21 Feb 2024 13:33:59 +1100 Subject: [PATCH] Fix mobile auth bug (#700) * Removed token expiration check * Bump versions so we can deploy auth fix --- .../Platforms/Android/AndroidManifest.xml | 2 +- src/MobileUI/Platforms/iOS/Info.plist | 2 +- .../Services/IAuthenticationService.cs | 29 ++----------------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/MobileUI/Platforms/Android/AndroidManifest.xml b/src/MobileUI/Platforms/Android/AndroidManifest.xml index 4d5512f4f..7ff39afd7 100644 --- a/src/MobileUI/Platforms/Android/AndroidManifest.xml +++ b/src/MobileUI/Platforms/Android/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/src/MobileUI/Platforms/iOS/Info.plist b/src/MobileUI/Platforms/iOS/Info.plist index 7f58e762f..921f52adc 100644 --- a/src/MobileUI/Platforms/iOS/Info.plist +++ b/src/MobileUI/Platforms/iOS/Info.plist @@ -33,7 +33,7 @@ CFBundleVersion 2 CFBundleShortVersionString - 3.0.7 + 3.0.8 ITSAppUsesNonExemptEncryption diff --git a/src/MobileUI/Services/IAuthenticationService.cs b/src/MobileUI/Services/IAuthenticationService.cs index ab80c5889..1174e1452 100644 --- a/src/MobileUI/Services/IAuthenticationService.cs +++ b/src/MobileUI/Services/IAuthenticationService.cs @@ -186,33 +186,13 @@ private async Task SettRefreshToken(AuthResult result) RefreshToken = result.RefreshToken; await SecureStorage.SetAsync(nameof(RefreshToken), RefreshToken); } - - if (result.RefreshTokenExpiration.HasValue) - { - _refreshTokenExpiry = result.RefreshTokenExpiration.Value; - Preferences.Set(nameof(_refreshTokenExpiry), _refreshTokenExpiry.ToUnixTimeSeconds()); - } - else - { - Preferences.Remove(nameof(_refreshTokenExpiry)); - } } public async Task RefreshLoginAsync() { RefreshToken = await SecureStorage.GetAsync(nameof(RefreshToken)); - var refreshTokenExpiry = Preferences.Get(nameof(_refreshTokenExpiry), 0L); - - bool refreshTokenExpired = false; - - if (refreshTokenExpiry > 0) - { - _refreshTokenExpiry = DateTimeOffset.FromUnixTimeSeconds(refreshTokenExpiry); - refreshTokenExpired = _refreshTokenExpiry < DateTimeOffset.Now.AddMinutes(2); - } - - if (!string.IsNullOrWhiteSpace(RefreshToken) && !refreshTokenExpired) + if (!string.IsNullOrWhiteSpace(RefreshToken)) { var oidcClient = new OidcClient(_options); @@ -275,8 +255,7 @@ private AuthResult GetAuthResult (TResult result) AccessToken = loginResult.AccessToken, RefreshToken = loginResult.RefreshToken, AccessTokenExpiration = loginResult.AccessTokenExpiration, - IdentityToken = loginResult.IdentityToken, - RefreshTokenExpiration = null + IdentityToken = loginResult.IdentityToken }; } else if (result is RefreshTokenResult refreshTokenResult) @@ -286,8 +265,7 @@ private AuthResult GetAuthResult (TResult result) AccessToken = refreshTokenResult.AccessToken, RefreshToken = refreshTokenResult.RefreshToken, IdentityToken = refreshTokenResult.IdentityToken, - AccessTokenExpiration = refreshTokenResult.AccessTokenExpiration, - RefreshTokenExpiration = DateTimeOffset.UtcNow.AddSeconds(refreshTokenResult.ExpiresIn) + AccessTokenExpiration = refreshTokenResult.AccessTokenExpiration }; } else @@ -302,7 +280,6 @@ private class AuthResult public string RefreshToken { get; set; } public string IdentityToken { get; set; } public DateTimeOffset AccessTokenExpiration { get; set; } - public DateTimeOffset? RefreshTokenExpiration { get; set; } } }