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
, servant >= 0.15 && < 0.19
, text >= 1.2.3.0 && < 1.3
, unordered-containers >= 0.2.9.0 && < 0.3
exposed-modules:
Servant.Auth
Servant.Auth.JWT

View File

@ -4,7 +4,7 @@ import Control.Lens ((^.))
import qualified Crypto.JWT as Jose
import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON,
toJSON)
import qualified Data.HashMap.Strict as HM
import qualified Data.Map as Map
import qualified Data.Text as T
@ -17,7 +17,7 @@ import qualified Data.Text as T
class FromJWT a where
decodeJWT :: 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"
Just v -> case fromJSON v of
Error e -> Left $ T.pack e