From d6eaddc3f794cbcf97dc17a02388e5cbe2f42cdd Mon Sep 17 00:00:00 2001 From: Nitin Prakash Date: Wed, 18 Sep 2024 15:58:06 +0530 Subject: [PATCH] Remove arbitrary 20 second expiry check --- azure-auth/Azure/Utils.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/azure-auth/Azure/Utils.hs b/azure-auth/Azure/Utils.hs index 978b969..64d0664 100644 --- a/azure-auth/Azure/Utils.hs +++ b/azure-auth/Azure/Utils.hs @@ -1,6 +1,6 @@ module Azure.Utils where -import Data.Time (addUTCTime, getCurrentTime, secondsToNominalDiffTime) +import Data.Time (getCurrentTime, secondsToNominalDiffTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import UnliftIO (MonadIO (..)) @@ -9,15 +9,13 @@ import Azure.Types (ExpiresOn) import qualified Data.Text as Text import qualified Text.Read as Text -{- | Check if an azure access token expiration time -is past or < 20 seconds from current time --} +-- | Check if an azure access token has expired isExpired :: MonadIO m => ExpiresOn -> m Bool isExpired expiresOn = do let timestamp = posixSecondsToUTCTime . secondsToNominalDiffTime <$> Text.readMaybe (Text.unpack expiresOn) case timestamp of Just time -> do currentTime <- liftIO getCurrentTime - return $ time <= addUTCTime 20 currentTime + return $ time <= currentTime Nothing -> return False