From 05ef0dd1d304a9c6f5037ca25c050d06ca7a167d Mon Sep 17 00:00:00 2001 From: akhesacaro Date: Thu, 18 Nov 2021 14:10:45 +0100 Subject: [PATCH] Allow using aeson 1 (lax with min-bounds) --- .../servant-auth-client/servant-auth-client.cabal | 4 ++-- .../servant-auth-server/servant-auth-server.cabal | 4 ++-- servant-auth/servant-auth/servant-auth.cabal | 5 +++-- servant-auth/servant-auth/src/Servant/Auth/JWT.hs | 11 +++++++++-- servant-client-core/servant-client-core.cabal | 2 +- servant-docs/servant-docs.cabal | 2 +- servant-server/servant-server.cabal | 4 ++-- servant-swagger/servant-swagger.cabal | 4 ++-- servant/servant.cabal | 2 +- 9 files changed, 23 insertions(+), 15 deletions(-) diff --git a/servant-auth/servant-auth-client/servant-auth-client.cabal b/servant-auth/servant-auth-client/servant-auth-client.cabal index 0a3b7f1d..7b8279b1 100644 --- a/servant-auth/servant-auth-client/servant-auth-client.cabal +++ b/servant-auth/servant-auth-client/servant-auth-client.cabal @@ -64,7 +64,7 @@ test-suite spec build-depends: hspec >= 2.5.5 && < 2.9 , QuickCheck >= 2.11.3 && < 2.15 - , aeson >= 2.0.1.0 && < 3 + , aeson >= 1.3.1.1 && < 3 , bytestring >= 0.10.6.0 && < 0.11 , http-client >= 0.5.13.1 && < 0.8 , http-types >= 0.12.2 && < 0.13 @@ -74,7 +74,7 @@ test-suite spec , transformers >= 0.4.2.0 && < 0.6 , wai >= 3.2.1.2 && < 3.3 , warp >= 3.2.25 && < 3.4 - , jose >= 0.9 && < 0.10 + , jose >= 0.7.0.0 && < 0.10 other-modules: Servant.Auth.ClientSpec default-language: Haskell2010 diff --git a/servant-auth/servant-auth-server/servant-auth-server.cabal b/servant-auth/servant-auth-server/servant-auth-server.cabal index fe1ecce5..b300b2ac 100644 --- a/servant-auth/servant-auth-server/servant-auth-server.cabal +++ b/servant-auth/servant-auth-server/servant-auth-server.cabal @@ -32,7 +32,7 @@ library ghc-options: -Wall build-depends: base >= 4.10 && < 4.16 - , aeson >= 2.0.1.0 && < 3 + , aeson >= 1.0.0.1 && < 3 , base64-bytestring >= 1.0.0.1 && < 2 , blaze-builder >= 0.4.1.0 && < 0.5 , bytestring >= 0.10.6.0 && < 0.11 @@ -41,7 +41,7 @@ library , data-default-class >= 0.1.2.0 && < 0.2 , entropy >= 0.4.1.3 && < 0.5 , http-types >= 0.12.2 && < 0.13 - , jose >= 0.9 && < 0.10 + , jose >= 0.7.0.0 && < 0.10 , lens >= 4.16.1 && < 5.1 , memory >= 0.14.16 && < 0.17 , monad-time >= 0.3.1.0 && < 0.4 diff --git a/servant-auth/servant-auth/servant-auth.cabal b/servant-auth/servant-auth/servant-auth.cabal index 49a4605e..36528d3e 100644 --- a/servant-auth/servant-auth/servant-auth.cabal +++ b/servant-auth/servant-auth/servant-auth.cabal @@ -35,11 +35,12 @@ library build-depends: base >= 4.10 && < 4.16 , containers >= 0.6 && < 0.7 - , aeson >= 2.0.1.0 && < 3 - , jose >= 0.9 && < 0.10 + , aeson >= 1.3.1.1 && < 3 + , jose >= 0.7.0.0 && < 0.10 , 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 diff --git a/servant-auth/servant-auth/src/Servant/Auth/JWT.hs b/servant-auth/servant-auth/src/Servant/Auth/JWT.hs index 8240770f..84bf17d0 100644 --- a/servant-auth/servant-auth/src/Servant/Auth/JWT.hs +++ b/servant-auth/servant-auth/src/Servant/Auth/JWT.hs @@ -1,10 +1,17 @@ +{-# LANGUAGE CPP #-} + module Servant.Auth.JWT where import Control.Lens ((^.)) import qualified Crypto.JWT as Jose import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON, toJSON) -import qualified Data.Map as Map +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Map as KM +#else +import qualified Data.HashMap.Strict as KM +#endif + import qualified Data.Text as T @@ -17,7 +24,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 Map.lookup "dat" (m ^. Jose.unregisteredClaims) of + decodeJWT m = case KM.lookup "dat" (m ^. Jose.unregisteredClaims) of Nothing -> Left "Missing 'dat' claim" Just v -> case fromJSON v of Error e -> Left $ T.pack e diff --git a/servant-client-core/servant-client-core.cabal b/servant-client-core/servant-client-core.cabal index 2c624719..21ac7923 100644 --- a/servant-client-core/servant-client-core.cabal +++ b/servant-client-core/servant-client-core.cabal @@ -70,7 +70,7 @@ library -- Other dependencies: Lower bound around what is in the latest Stackage LTS. -- Here can be exceptions if we really need features from the newer versions. build-depends: - aeson >= 2.0.1.0 && < 3 + aeson >= 1.4.1.0 && < 3 , base-compat >= 0.10.5 && < 0.12 , base64-bytestring >= 1.0.0.1 && < 1.3 , exceptions >= 0.10.0 && < 0.11 diff --git a/servant-docs/servant-docs.cabal b/servant-docs/servant-docs.cabal index bf0dc7d8..857e87a9 100644 --- a/servant-docs/servant-docs.cabal +++ b/servant-docs/servant-docs.cabal @@ -52,7 +52,7 @@ library -- Other dependencies: Lower bound around what is in the latest Stackage LTS. -- Here can be exceptions if we really need features from the newer versions. build-depends: - aeson >= 2.0.1.0 && < 3 + aeson >= 1.4.1.0 && < 3 , aeson-pretty >= 0.8.5 && < 0.9 , base-compat >= 0.10.5 && < 0.12 , case-insensitive >= 1.2.0.11 && < 1.3 diff --git a/servant-server/servant-server.cabal b/servant-server/servant-server.cabal index dfd0f6dd..6fac8a93 100644 --- a/servant-server/servant-server.cabal +++ b/servant-server/servant-server.cabal @@ -114,7 +114,7 @@ executable greet , text build-depends: - aeson >= 2.0.1.0 && < 3 + aeson >= 1.4.1.0 && < 3 , warp >= 3.2.25 && < 3.4 test-suite spec @@ -157,7 +157,7 @@ test-suite spec -- Additional dependencies build-depends: - aeson >= 2.0.1.0 && < 3 + aeson >= 1.4.1.0 && < 3 , directory >= 1.3.0.0 && < 1.4 , hspec >= 2.6.0 && < 2.9 , hspec-wai >= 0.10.1 && < 0.12 diff --git a/servant-swagger/servant-swagger.cabal b/servant-swagger/servant-swagger.cabal index 8960a86d..f4595e10 100644 --- a/servant-swagger/servant-swagger.cabal +++ b/servant-swagger/servant-swagger.cabal @@ -68,7 +68,7 @@ library Servant.Swagger.Internal.TypeLevel.Every Servant.Swagger.Internal.TypeLevel.TMap hs-source-dirs: src - build-depends: aeson >=2.0.1.0 && <3 + build-depends: aeson >=1.4.2.0 && <3 , aeson-pretty >=0.8.7 && <0.9 , base >=4.9.1.0 && <5 , base-compat >=0.10.5 && <0.12 @@ -108,7 +108,7 @@ test-suite spec build-tool-depends: hspec-discover:hspec-discover >=2.6.0 && <2.8 build-depends: base , base-compat - , aeson >=2.0.1.0 && <3 + , aeson >=1.4.2.0 && <3 , hspec >=2.6.0 && <2.8 , QuickCheck , lens diff --git a/servant/servant.cabal b/servant/servant.cabal index 8d315516..b2e65c45 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -98,7 +98,7 @@ library -- Here can be exceptions if we really need features from the newer versions. build-depends: base-compat >= 0.10.5 && < 0.12 - , aeson >= 2.0.1.0 && < 3 + , aeson >= 1.4.1.0 && < 3 , attoparsec >= 0.13.2.2 && < 0.15 , bifunctors >= 5.5.3 && < 5.6 , case-insensitive >= 1.2.0.11 && < 1.3