Skip to content

Commit

Permalink
Remove arbitrary 20 second expiry check
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Sep 18, 2024
1 parent 4d9d19f commit d6eaddc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions azure-auth/Azure/Utils.hs
Original file line number Diff line number Diff line change
@@ -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 (..))

Expand All @@ -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

0 comments on commit d6eaddc

Please sign in to comment.