fixing servant-auth (aeson 2.0 bump)

This commit is contained in:
akhesacaro 2021-11-14 14:33:43 +01:00
parent 8af80d35a0
commit efffc70919
2 changed files with 2 additions and 3 deletions

View file

@ -40,7 +40,6 @@ library
, lens >= 4.16.1 && < 5.1 , lens >= 4.16.1 && < 5.1
, servant >= 0.15 && < 0.19 , servant >= 0.15 && < 0.19
, text >= 1.2.3.0 && < 1.3 , text >= 1.2.3.0 && < 1.3
, unordered-containers >= 0.2.9.0 && < 0.3
exposed-modules: exposed-modules:
Servant.Auth Servant.Auth
Servant.Auth.JWT Servant.Auth.JWT

View file

@ -4,7 +4,7 @@ import Control.Lens ((^.))
import qualified Crypto.JWT as Jose import qualified Crypto.JWT as Jose
import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON, import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON,
toJSON) toJSON)
import qualified Data.HashMap.Strict as HM import qualified Data.Map as Map
import qualified Data.Text as T import qualified Data.Text as T
@ -17,7 +17,7 @@ import qualified Data.Text as T
class FromJWT a where class FromJWT a where
decodeJWT :: Jose.ClaimsSet -> Either T.Text a decodeJWT :: Jose.ClaimsSet -> Either T.Text a
default decodeJWT :: FromJSON a => Jose.ClaimsSet -> Either T.Text a default decodeJWT :: FromJSON a => Jose.ClaimsSet -> Either T.Text a
decodeJWT m = case HM.lookup "dat" (m ^. Jose.unregisteredClaims) of decodeJWT m = case Map.lookup "dat" (m ^. Jose.unregisteredClaims) of
Nothing -> Left "Missing 'dat' claim" Nothing -> Left "Missing 'dat' claim"
Just v -> case fromJSON v of Just v -> case fromJSON v of
Error e -> Left $ T.pack e Error e -> Left $ T.pack e