Allow mtl-2.3, require jose-0.10 (#1627)

This commit is contained in:
Janus Troelsen 2022-11-17 09:58:52 -06:00 committed by GitHub
parent ad25e98e19
commit 8f081bd9ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 29 additions and 28 deletions

View File

@ -74,7 +74,7 @@ test-suite spec
, transformers >= 0.4.2.0 && < 0.6 , transformers >= 0.4.2.0 && < 0.6
, wai >= 3.2.1.2 && < 3.3 , wai >= 3.2.1.2 && < 3.3
, warp >= 3.2.25 && < 3.4 , warp >= 3.2.25 && < 3.4
, jose >= 0.7.0.0 && < 0.10 , jose >= 0.10 && < 0.11
other-modules: other-modules:
Servant.Auth.ClientSpec Servant.Auth.ClientSpec
default-language: Haskell2010 default-language: Haskell2010

View File

@ -41,11 +41,11 @@ library
, data-default-class >= 0.1.2.0 && < 0.2 , data-default-class >= 0.1.2.0 && < 0.2
, entropy >= 0.4.1.3 && < 0.5 , entropy >= 0.4.1.3 && < 0.5
, http-types >= 0.12.2 && < 0.13 , http-types >= 0.12.2 && < 0.13
, jose >= 0.7.0.0 && < 0.10 , jose >= 0.10 && < 0.11
, lens >= 4.16.1 && < 5.3 , lens >= 4.16.1 && < 5.3
, memory >= 0.14.16 && < 0.19 , memory >= 0.14.16 && < 0.19
, monad-time >= 0.3.1.0 && < 0.4 , monad-time >= 0.3.1.0 && < 0.4
, mtl >= 2.2.2 && < 2.3 , mtl ^>= 2.2.2 || ^>= 2.3.1
, servant >= 0.13 && < 0.20 , servant >= 0.13 && < 0.20
, servant-auth == 0.4.* , servant-auth == 0.4.*
, servant-server >= 0.13 && < 0.20 , servant-server >= 0.13 && < 0.20

View File

@ -2,6 +2,7 @@
module Servant.Auth.Server.Internal.Cookie where module Servant.Auth.Server.Internal.Cookie where
import Blaze.ByteString.Builder (toByteString) import Blaze.ByteString.Builder (toByteString)
import Control.Monad (MonadPlus(..), guard)
import Control.Monad.Except import Control.Monad.Except
import Control.Monad.Reader import Control.Monad.Reader
import qualified Crypto.JOSE as Jose import qualified Crypto.JOSE as Jose

View File

@ -1,18 +1,14 @@
module Servant.Auth.Server.Internal.JWT where module Servant.Auth.Server.Internal.JWT where
import Control.Lens import Control.Lens
import Control.Monad.Except import Control.Monad (MonadPlus(..), guard)
import Control.Monad.Reader import Control.Monad.Reader
import qualified Crypto.JOSE as Jose import qualified Crypto.JOSE as Jose
import qualified Crypto.JWT as Jose import qualified Crypto.JWT as Jose
import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON,
toJSON)
import Data.ByteArray (constEq) import Data.ByteArray (constEq)
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Lazy as BSL
import qualified Data.HashMap.Strict as HM
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Data.Time (UTCTime) import Data.Time (UTCTime)
import Network.Wai (requestHeaders) import Network.Wai (requestHeaders)
@ -42,7 +38,7 @@ jwtAuthCheck jwtSettings = do
-- token expires. -- token expires.
makeJWT :: ToJWT a makeJWT :: ToJWT a
=> a -> JWTSettings -> Maybe UTCTime -> IO (Either Jose.Error BSL.ByteString) => a -> JWTSettings -> Maybe UTCTime -> IO (Either Jose.Error BSL.ByteString)
makeJWT v cfg expiry = runExceptT $ do makeJWT v cfg expiry = Jose.runJOSE $ do
bestAlg <- Jose.bestJWSAlg $ signingKey cfg bestAlg <- Jose.bestJWSAlg $ signingKey cfg
let alg = fromMaybe bestAlg $ jwtAlg cfg let alg = fromMaybe bestAlg $ jwtAlg cfg
ejwt <- Jose.signClaims (signingKey cfg) ejwt <- Jose.signClaims (signingKey cfg)
@ -59,7 +55,7 @@ makeJWT v cfg expiry = runExceptT $ do
verifyJWT :: FromJWT a => JWTSettings -> BS.ByteString -> IO (Maybe a) verifyJWT :: FromJWT a => JWTSettings -> BS.ByteString -> IO (Maybe a)
verifyJWT jwtCfg input = do verifyJWT jwtCfg input = do
keys <- validationKeys jwtCfg keys <- validationKeys jwtCfg
verifiedJWT <- runExceptT $ do verifiedJWT <- Jose.runJOSE $ do
unverifiedJWT <- Jose.decodeCompact (BSL.fromStrict input) unverifiedJWT <- Jose.decodeCompact (BSL.fromStrict input)
Jose.verifyClaims Jose.verifyClaims
(jwtSettingsToJwtValidationSettings jwtCfg) (jwtSettingsToJwtValidationSettings jwtCfg)

View File

@ -2,6 +2,7 @@
module Servant.Auth.Server.Internal.Types where module Servant.Auth.Server.Internal.Types where
import Control.Applicative import Control.Applicative
import Control.Monad (MonadPlus(..), ap)
import Control.Monad.Reader import Control.Monad.Reader
import Control.Monad.Time import Control.Monad.Time
import Data.Monoid (Monoid (..)) import Data.Monoid (Monoid (..))

View File

@ -6,13 +6,12 @@ module Servant.Auth.ServerSpec (spec) where
#endif #endif
import Control.Lens import Control.Lens
import Control.Monad.Except (runExceptT)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Crypto.JOSE (Alg (HS256, None), Error, import Crypto.JOSE (Alg (HS256, None), Error,
JWK, JWSHeader, JWK, JWSHeader,
KeyMaterialGenParam (OctGenParam), KeyMaterialGenParam (OctGenParam),
ToCompact, encodeCompact, ToCompact, encodeCompact,
genJWK, newJWSHeader) genJWK, newJWSHeader, runJOSE)
import Crypto.JWT (Audience (..), ClaimsSet, import Crypto.JWT (Audience (..), ClaimsSet,
NumericDate (NumericDate), NumericDate (NumericDate),
SignedJWT, SignedJWT,
@ -540,7 +539,7 @@ addJwtToHeader jwt = case jwt of
$ defaults & header "Authorization" .~ ["Bearer " <> BSL.toStrict v] $ defaults & header "Authorization" .~ ["Bearer " <> BSL.toStrict v]
createJWT :: JWK -> JWSHeader () -> ClaimsSet -> IO (Either Error Crypto.JWT.SignedJWT) createJWT :: JWK -> JWSHeader () -> ClaimsSet -> IO (Either Error Crypto.JWT.SignedJWT)
createJWT k a b = runExceptT $ signClaims k a b createJWT k a b = runJOSE $ signClaims k a b
addJwtToCookie :: ToCompact a => CookieSettings -> Either Error a -> IO Options addJwtToCookie :: ToCompact a => CookieSettings -> Either Error a -> IO Options
addJwtToCookie ccfg jwt = case jwt >>= (return . encodeCompact) of addJwtToCookie ccfg jwt = case jwt >>= (return . encodeCompact) of

View File

@ -36,7 +36,7 @@ library
base >= 4.10 && < 4.18 base >= 4.10 && < 4.18
, containers >= 0.6 && < 0.7 , containers >= 0.6 && < 0.7
, aeson >= 1.3.1.1 && < 3 , aeson >= 1.3.1.1 && < 3
, jose >= 0.7.0.0 && < 0.10 , jose >= 0.10 && < 0.11
, lens >= 4.16.1 && < 5.3 , lens >= 4.16.1 && < 5.3
, servant >= 0.15 && < 0.20 , servant >= 0.15 && < 0.20
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1

View File

@ -56,7 +56,7 @@ library
, containers >= 0.5.7.1 && < 0.7 , containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5 , deepseq >= 1.4.2.0 && < 1.5
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1
, transformers >= 0.5.2.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.7
, template-haskell >= 2.11.1.0 && < 2.20 , template-haskell >= 2.11.1.0 && < 2.20
if !impl(ghc >= 8.2) if !impl(ghc >= 8.2)

View File

@ -48,7 +48,7 @@ library
, http-media >=0.6.2 && <0.9 , http-media >=0.6.2 && <0.9
, http-types >=0.12 && <0.13 , http-types >=0.12 && <0.13
, monad-control >=1.0.0.4 && <1.1 , monad-control >=1.0.0.4 && <1.1
, mtl >=2.2.2 && <2.3 , mtl ^>=2.2.2 || ^>=2.3.1
, semigroupoids >=5.3 && <5.4 , semigroupoids >=5.3 && <5.4
, string-conversions >=0.3 && <0.5 , string-conversions >=0.3 && <0.5
, transformers >=0.3 && <0.6 , transformers >=0.3 && <0.6

View File

@ -45,11 +45,11 @@ library
, bytestring >= 0.10.8.1 && < 0.12 , bytestring >= 0.10.8.1 && < 0.12
, containers >= 0.5.7.1 && < 0.7 , containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5 , deepseq >= 1.4.2.0 && < 1.5
, mtl >= 2.2.2 && < 2.3 , mtl ^>= 2.2.2 || ^>= 2.3.1
, stm >= 2.4.5.1 && < 2.6 , stm >= 2.4.5.1 && < 2.6
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1
, time >= 1.6.0.1 && < 1.13 , time >= 1.6.0.1 && < 1.13
, transformers >= 0.5.2.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.7
if !impl(ghc >= 8.2) if !impl(ghc >= 8.2)
build-depends: build-depends:

View File

@ -24,7 +24,8 @@ import Control.DeepSeq
(NFData, force) (NFData, force)
import Control.Exception import Control.Exception
(evaluate, throwIO) (evaluate, throwIO)
import Control.Monad () import Control.Monad
(unless)
import Control.Monad.Base import Control.Monad.Base
(MonadBase (..)) (MonadBase (..))
import Control.Monad.Codensity import Control.Monad.Codensity

View File

@ -31,7 +31,7 @@ library
base >=4.9 && <5 base >=4.9 && <5
, bytestring >=0.10.8.1 && <0.12 , bytestring >=0.10.8.1 && <0.12
, conduit >=1.3.1 && <1.4 , conduit >=1.3.1 && <1.4
, mtl >=2.2.2 && <2.3 , mtl ^>=2.2.2 || ^>=2.3.1
, resourcet >=1.2.2 && <1.3 , resourcet >=1.2.2 && <1.3
, servant >=0.15 && <0.20 , servant >=0.15 && <0.20
, unliftio-core >=0.1.2.0 && <0.3 , unliftio-core >=0.1.2.0 && <0.3

View File

@ -42,10 +42,10 @@ library
, bytestring >= 0.10.8.1 && < 0.12 , bytestring >= 0.10.8.1 && < 0.12
, containers >= 0.5.7.1 && < 0.7 , containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5 , deepseq >= 1.4.2.0 && < 1.5
, mtl >= 2.2.2 && < 2.3 , mtl ^>= 2.2.2 || ^>= 2.3.1
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1
, time >= 1.6.0.1 && < 1.13 , time >= 1.6.0.1 && < 1.13
, transformers >= 0.5.2.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.7
if !impl(ghc >= 8.2) if !impl(ghc >= 8.2)
build-depends: build-depends:

View File

@ -31,7 +31,7 @@ library
base >=4.9 && <5 base >=4.9 && <5
, bytestring >=0.10.8.1 && <0.12 , bytestring >=0.10.8.1 && <0.12
, machines >=0.6.4 && <0.8 , machines >=0.6.4 && <0.8
, mtl >=2.2.2 && <2.3 , mtl ^>=2.2.2 || ^>=2.3.1
, servant >=0.15 && <0.20 , servant >=0.15 && <0.20
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010

View File

@ -32,7 +32,7 @@ library
, bytestring >=0.10.8.1 && <0.12 , bytestring >=0.10.8.1 && <0.12
, pipes >=4.3.9 && <4.4 , pipes >=4.3.9 && <4.4
, pipes-safe >=2.3.1 && <2.4 , pipes-safe >=2.3.1 && <2.4
, mtl >=2.2.2 && <2.3 , mtl ^>=2.2.2 || ^>=2.3.1
, monad-control >=1.0.2.3 && <1.1 , monad-control >=1.0.2.3 && <1.1
, servant >=0.15 && <0.20 , servant >=0.15 && <0.20
hs-source-dirs: src hs-source-dirs: src

View File

@ -64,9 +64,9 @@ library
, bytestring >= 0.10.8.1 && < 0.12 , bytestring >= 0.10.8.1 && < 0.12
, constraints >= 0.2 && < 0.14 , constraints >= 0.2 && < 0.14
, containers >= 0.5.7.1 && < 0.7 , containers >= 0.5.7.1 && < 0.7
, mtl >= 2.2.2 && < 2.3 , mtl ^>= 2.2.2 || ^>= 2.3.1
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1
, transformers >= 0.5.2.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.7
, filepath >= 1.4.1.1 && < 1.5 , filepath >= 1.4.1.1 && < 1.5
-- Servant dependencies -- Servant dependencies

View File

@ -83,9 +83,9 @@ library
base >= 4.9 && < 4.18 base >= 4.9 && < 4.18
, bytestring >= 0.10.8.1 && < 0.12 , bytestring >= 0.10.8.1 && < 0.12
, constraints >= 0.2 , constraints >= 0.2
, mtl >= 2.2.2 && < 2.3 , mtl ^>= 2.2.2 || ^>= 2.3.1
, sop-core >= 0.4.0.0 && < 0.6 , sop-core >= 0.4.0.0 && < 0.6
, transformers >= 0.5.2.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.7
, text >= 1.2.3.0 && < 2.1 , text >= 1.2.3.0 && < 2.1

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-} {-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
@ -154,8 +155,10 @@ instance (Applicative m, Show1 m, Show a) => Show (StepT m a) where
-- | >>> lift [1,2,3] :: StepT [] Int -- | >>> lift [1,2,3] :: StepT [] Int
-- Effect [Yield 1 Stop,Yield 2 Stop,Yield 3 Stop] -- Effect [Yield 1 Stop,Yield 2 Stop,Yield 3 Stop]
-- --
#if !MIN_VERSION_transformers(0,6,0)
instance MonadTrans StepT where instance MonadTrans StepT where
lift = Effect . fmap (`Yield` Stop) lift = Effect . fmap (`Yield` Stop)
#endif
instance MFunctor StepT where instance MFunctor StepT where
hoist f = go where hoist f = go where