servant-auth 0.4.2.0 → 0.4.9.2
raw patch · 4 files changed
+34/−32 lines, 4 filesdep ~basedep ~containersdep ~josesetup-changed
Dependency ranges changed: base, containers, jose, servant
Files
- Setup.hs +1/−0
- servant-auth.cabal +6/−6
- src/Servant/Auth.hs +17/−15
- src/Servant/Auth/JWT.hs +10/−11
Setup.hs view
@@ -1,2 +1,3 @@ import Distribution.Simple+ main = defaultMain
servant-auth.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: servant-auth-version: 0.4.2.0+version: 0.4.9.2 synopsis: Authentication combinators for servant description: This package provides an @Auth@ combinator for 'servant'. This combinator allows using different authentication schemes in a straightforward way,@@ -18,7 +18,7 @@ copyright: (c) Julian K. Arni license: BSD-3-Clause license-file: LICENSE-tested-with: GHC==8.6.5, GHC==8.8.4, GHC ==8.10.7, GHC ==9.0.2, GHC ==9.2.7, GHC ==9.4.4, GHC ==9.10.1+tested-with: GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.4 || ==9.10.1 || ==9.12.1 build-type: Simple extra-source-files: CHANGELOG.md@@ -33,12 +33,12 @@ default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators ghc-options: -Wall build-depends:- base >= 4.14 && < 4.21- , containers >= 0.6 && < 0.8+ base >= 4.16.4.0 && < 4.22+ , containers >=0.6.5.1 && < 0.9 , aeson >= 2.0 && < 3- , jose >= 0.10 && < 0.12+ , jose >= 0.10 && < 0.13 , lens >= 4.16.1 && < 5.4- , servant >= 0.20.2 && < 0.21+ , servant >= 0.20.3 && < 0.21 , text >= 1.2.3.0 && < 2.2 , unordered-containers >= 0.2.9.0 && < 0.3 exposed-modules:
src/Servant/Auth.hs view
@@ -1,14 +1,14 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+ module Servant.Auth where -import Data.Kind (Type)-import Data.Proxy (Proxy(..))-import Servant.API ((:>))-import Servant.Links (HasLink (..))+import Data.Kind (Type)+import Data.Proxy (Proxy (..))+import Servant.API ((:>))+import Servant.Links (HasLink (..)) -- * Authentication @@ -17,13 +17,15 @@ data Auth (auths :: [Type]) val -- | A @HasLink@ instance for @Auth@-instance HasLink sub => HasLink (Auth (tag :: [Type]) value :> sub) where+instance HasLink sub => HasLink (Auth (tag :: [Type]) value :> sub) #if MIN_VERSION_servant(0,14,0)- type MkLink (Auth (tag :: [Type]) value :> sub) a = MkLink sub a- toLink toA _ = toLink toA (Proxy :: Proxy sub)+ where+ type MkLink (Auth (tag :: [Type]) value :> sub) a = MkLink sub a+ toLink toA _ = toLink toA (Proxy :: Proxy sub) #else- type MkLink (Auth (tag :: [Type]) value :> sub) = MkLink sub- toLink _ = toLink (Proxy :: Proxy sub)+ where+ type MkLink (Auth (tag :: [Type]) value :> sub) = MkLink sub+ toLink _ = toLink (Proxy :: Proxy sub) #endif -- ** Combinators@@ -43,11 +45,11 @@ -- header, for XSRF protection. data Cookie - -- We could use 'servant''s BasicAuth, but then we don't get control over the -- documentation, and we'd have to polykind everything. (Also, we don't -- currently depend on servant!) --+ -- | Basic Auth. data BasicAuth
src/Servant/Auth/JWT.hs view
@@ -2,21 +2,20 @@ module Servant.Auth.JWT where -import Control.Lens ((^.))-import qualified Crypto.JWT as Jose-import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON,- toJSON)-#if MIN_VERSION_aeson(2,0,0) -import qualified Data.Map as KM -#else -import qualified Data.HashMap.Strict as KM +import Control.Lens ((^.))+import qualified Crypto.JWT as Jose+import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON, toJSON)+#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-+import qualified Data.Text as T -- This should probably also be from ClaimSet --+ -- | How to decode data from a JWT. -- -- The default implementation assumes the data is stored in the unregistered@@ -26,7 +25,7 @@ default decodeJWT :: FromJSON a => Jose.ClaimsSet -> Either T.Text a decodeJWT m = case KM.lookup "dat" (m ^. Jose.unregisteredClaims) of Nothing -> Left "Missing 'dat' claim"- Just v -> case fromJSON v of+ Just v -> case fromJSON v of Error e -> Left $ T.pack e Success a -> Right a