diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Crypto/Macaroon/Verifier.hs | 6 | ||||
-rw-r--r-- | src/Crypto/Macaroon/Verifier/Internal.hs | 2 |
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 | ||
26 | import Control.Monad | 26 | import Control.Applicative |
27 | import Control.Monad hiding (forM) | ||
27 | import Control.Monad.IO.Class | 28 | import Control.Monad.IO.Class |
28 | import Data.Attoparsec.ByteString | 29 | import Data.Attoparsec.ByteString |
29 | import Data.Attoparsec.ByteString.Char8 | 30 | import Data.Attoparsec.ByteString.Char8 |
30 | import Data.Bool | 31 | import Data.Bool |
32 | import Data.Traversable | ||
31 | import qualified Data.ByteString as BS | 33 | import qualified Data.ByteString as BS |
32 | import Data.Either.Combinators | 34 | import 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 |
71 | verify :: MonadIO m => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) | 73 | verify :: (Functor m, MonadIO m) => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) |
72 | verify secret verifiers m = join <$> forM (verifySig secret m) (verifyCavs verifiers) | 74 | verify 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 |
61 | verifyCavs :: MonadIO m | 61 | verifyCavs :: (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) |