]> git.immae.eu Git - github/fretlink/hmacaroons.git/blobdiff - src/Crypto/Macaroon/Verifier/Internal.hs
Merge branch 'verification'
[github/fretlink/hmacaroons.git] / src / Crypto / Macaroon / Verifier / Internal.hs
index 2af55d3b14d577d8a09b8d27f4b19a45e77f398d..b3ad7f2c569d11d11ac99d459e0e8175515f64f9 100644 (file)
@@ -14,6 +14,7 @@ Portability : portable
 -}
 module Crypto.Macaroon.Verifier.Internal where
 
+import           Control.Applicative
 import           Control.Monad
 import           Control.Monad.IO.Class
 import           Crypto.Hash
@@ -29,16 +30,16 @@ import           Data.Monoid
 import           Crypto.Macaroon.Internal
 
 -- | Type representing different validation errors.
--- Only 'ParseError' and 'ValidatorError' are exported, 'SigMismatch' and
--- 'NoVerifier' are used internally and should not be used by the user
+-- Only 'ParseError' and 'ValidatorError' are exported, @SigMismatch@ and
+-- @NoVerifier@ are used internally and should not be used by the user
 data ValidationError = SigMismatch -- ^ Signatures do not match
                      | NoVerifier -- ^ No verifier can handle a given caveat
                      | ParseError String -- ^ A verifier had a parse error
                      | ValidatorError String -- ^ A verifier failed
                      deriving (Show,Eq)
 
--- | The 'Monoid' instance is written so 'SigMismatch' is an annihilator,
--- and 'NoVerifier' is the identity element
+-- | The 'Monoid' instance is written so @SigMismatch@ is an annihilator,
+-- and @NoVerifier@ is the identity element
 instance Monoid ValidationError where
     mempty = NoVerifier
     NoVerifier `mappend` e = e
@@ -57,7 +58,7 @@ verifySig k m = bool (Left SigMismatch) (Right m) $
     derivedKey = toBytes (hmac "macaroons-key-generator" k :: HMAC SHA256)
 
 -- | Given a list of verifiers, verify each caveat of the given macaroon
-verifyCavs :: MonadIO m
+verifyCavs :: (Functor m, MonadIO m)
            => [Caveat -> m (Maybe (Either ValidationError ()))]
            -> Macaroon
            -> m (Either ValidationError Macaroon)