mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
5b54f9d766
* add expiry time to webhook user info This also adds an optional message to webhook errors: if we fail to parse an expiry time, we will log a warning with the parse error. * refactored Auth This change had one main goal: put in common all expiry time extraction code between the JWT and WebHook parts of the code. Furthermore, this change also moves all WebHook specific code to its own module, similarly to what is done for JWT. * Remove dependency on string-conversions in favor of text-conversions string-conversions silently uses UTF8 instead of being explicit about it, and it uses lenientDecode when decoding ByteStrings when it’s usually better to reject invalid UTF8 input outright. text-conversions solves both those problems. Co-authored-by: Alexis King <lexi.lambda@gmail.com>
18 lines
584 B
Haskell
18 lines
584 B
Haskell
module Data.Parser.Expires
|
|
( parseExpirationTime
|
|
) where
|
|
|
|
import Control.Monad.Except
|
|
import Data.Text.Conversions
|
|
import Data.Time.Clock
|
|
import Data.Time.Format (defaultTimeLocale, parseTimeM)
|
|
|
|
import Hasura.Prelude
|
|
|
|
|
|
-- | Extracts an absolute expiration time from a Expires header.
|
|
parseExpirationTime :: MonadError String m => Text -> m UTCTime
|
|
parseExpirationTime = fromText
|
|
>>> parseTimeM True defaultTimeLocale "%a, %d %b %Y %T GMT"
|
|
>>> (`onNothing` throwError "Value of Expires header is not a valid timestamp")
|