Update jwtIsValid API to return IO Bool
I need IO for: - Getting the current time to validate `exp` - Making an HTTP request to Google's token verifier endpoint
This commit is contained in:
parent
3eaf6e5aea
commit
926d8e643e
2 changed files with 6 additions and 6 deletions
|
@ -10,5 +10,5 @@ import Web.JWT
|
||||||
-- * The value of `iss` matches is "accounts.google.com" or
|
-- * The value of `iss` matches is "accounts.google.com" or
|
||||||
-- "https://accounts.google.com"
|
-- "https://accounts.google.com"
|
||||||
-- * The `exp` time has not passed
|
-- * The `exp` time has not passed
|
||||||
jwtIsValid :: JWT UnverifiedJWT -> Bool
|
jwtIsValid :: JWT UnverifiedJWT -> IO Bool
|
||||||
jwtIsValid jwt = False
|
jwtIsValid jwt = pure False
|
||||||
|
|
|
@ -18,12 +18,12 @@ main = hspec $ do
|
||||||
let mJWT = F.defaultJWTFields { F.overwriteSigner = hmacSecret "wrong" }
|
let mJWT = F.defaultJWTFields { F.overwriteSigner = hmacSecret "wrong" }
|
||||||
|> F.googleJWT
|
|> F.googleJWT
|
||||||
case mJWT of
|
case mJWT of
|
||||||
Nothing -> True == False
|
Nothing -> True `shouldBe` False
|
||||||
Just jwt -> GoogleSignIn.jwtIsValid jwt == False
|
Just jwt -> GoogleSignIn.jwtIsValid jwt `shouldReturn` False
|
||||||
|
|
||||||
it "returns false when the aud field doesn't match my client ID" $ do
|
it "returns false when the aud field doesn't match my client ID" $ do
|
||||||
let mJWT = F.defaultJWTFields { F.overwriteAud = stringOrURI "wrong" }
|
let mJWT = F.defaultJWTFields { F.overwriteAud = stringOrURI "wrong" }
|
||||||
|> F.googleJWT
|
|> F.googleJWT
|
||||||
case mJWT of
|
case mJWT of
|
||||||
Nothing -> True == False
|
Nothing -> True `shouldBe` False
|
||||||
Just jwt -> GoogleSignIn.jwtIsValid jwt == False
|
Just jwt -> GoogleSignIn.jwtIsValid jwt `shouldReturn` False
|
||||||
|
|
Loading…
Reference in a new issue