aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Crypto/Macaroon
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-08-17 18:56:12 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-08-17 18:56:12 +0200
commita11f20be0fadf21cc96164b49305b59ac7445aa2 (patch)
tree00a8eec6be63241f0e40a4306e0eae436b6ff11c /src/Crypto/Macaroon
parentcb1ee5df44a6a68f32e7f8413cee4a7105d37b4b (diff)
downloadhmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.tar.gz
hmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.tar.zst
hmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.zip
ghc<7.10.1 compat
Diffstat (limited to 'src/Crypto/Macaroon')
-rw-r--r--src/Crypto/Macaroon/Verifier.hs6
-rw-r--r--src/Crypto/Macaroon/Verifier/Internal.hs2
2 files changed, 5 insertions, 3 deletions
diff --git a/src/Crypto/Macaroon/Verifier.hs b/src/Crypto/Macaroon/Verifier.hs
index a739437..4fc6aff 100644
--- a/src/Crypto/Macaroon/Verifier.hs
+++ b/src/Crypto/Macaroon/Verifier.hs
@@ -23,11 +23,13 @@ module Crypto.Macaroon.Verifier (
23) where 23) where
24 24
25 25
26import Control.Monad 26import Control.Applicative
27import Control.Monad hiding (forM)
27import Control.Monad.IO.Class 28import Control.Monad.IO.Class
28import Data.Attoparsec.ByteString 29import Data.Attoparsec.ByteString
29import Data.Attoparsec.ByteString.Char8 30import Data.Attoparsec.ByteString.Char8
30import Data.Bool 31import Data.Bool
32import Data.Traversable
31import qualified Data.ByteString as BS 33import qualified Data.ByteString as BS
32import Data.Either.Combinators 34import Data.Either.Combinators
33 35
@@ -68,7 +70,7 @@ import Crypto.Macaroon.Verifier.Internal
68-- caveat, parsed it and invalidated it; 70-- caveat, parsed it and invalidated it;
69-- * 'Just' ('Right' '()') if the verifier has successfully verified the 71-- * 'Just' ('Right' '()') if the verifier has successfully verified the
70-- given caveat 72-- given caveat
71verify :: MonadIO m => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) 73verify :: (Functor m, MonadIO m) => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon)
72verify secret verifiers m = join <$> forM (verifySig secret m) (verifyCavs verifiers) 74verify secret verifiers m = join <$> forM (verifySig secret m) (verifyCavs verifiers)
73 75
74 76
diff --git a/src/Crypto/Macaroon/Verifier/Internal.hs b/src/Crypto/Macaroon/Verifier/Internal.hs
index 73eb66a..5126b2e 100644
--- a/src/Crypto/Macaroon/Verifier/Internal.hs
+++ b/src/Crypto/Macaroon/Verifier/Internal.hs
@@ -58,7 +58,7 @@ verifySig k m = bool (Left SigMismatch) (Right m) $
58 derivedKey = toBytes (hmac "macaroons-key-generator" k :: HMAC SHA256) 58 derivedKey = toBytes (hmac "macaroons-key-generator" k :: HMAC SHA256)
59 59
60-- | Given a list of verifiers, verify each caveat of the given macaroon 60-- | Given a list of verifiers, verify each caveat of the given macaroon
61verifyCavs :: MonadIO m 61verifyCavs :: (Functor m, MonadIO m)
62 => [Caveat -> m (Maybe (Either ValidationError ()))] 62 => [Caveat -> m (Maybe (Either ValidationError ()))]
63 -> Macaroon 63 -> Macaroon
64 -> m (Either ValidationError Macaroon) 64 -> m (Either ValidationError Macaroon)