diff options
-rw-r--r-- | default.nix | 5 | ||||
-rw-r--r-- | hmacaroons.cabal | 6 | ||||
-rw-r--r-- | src/Crypto/Macaroon/Verifier.hs | 6 | ||||
-rw-r--r-- | src/Crypto/Macaroon/Verifier/Internal.hs | 2 | ||||
-rw-r--r-- | test/Crypto/Macaroon/Instances.hs | 1 |
5 files changed, 12 insertions, 8 deletions
diff --git a/default.nix b/default.nix index b1404ef..a392583 100644 --- a/default.nix +++ b/default.nix | |||
@@ -4,7 +4,7 @@ | |||
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
6 | pname = "hmacaroons"; | 6 | pname = "hmacaroons"; |
7 | version = "0.2.0.0"; | 7 | version = "0.4.0.0"; |
8 | src = ./.; | 8 | src = ./.; |
9 | buildDepends = [ | 9 | buildDepends = [ |
10 | attoparsec base base64-bytestring byteable bytestring cereal | 10 | attoparsec base base64-bytestring byteable bytestring cereal |
@@ -12,7 +12,8 @@ mkDerivation { | |||
12 | ]; | 12 | ]; |
13 | testDepends = [ | 13 | testDepends = [ |
14 | attoparsec base base64-bytestring byteable bytestring cereal | 14 | attoparsec base base64-bytestring byteable bytestring cereal |
15 | cryptohash either hex QuickCheck tasty tasty-hunit tasty-quickcheck | 15 | cryptohash deepseq either hex QuickCheck tasty tasty-hunit |
16 | tasty-quickcheck transformers | ||
16 | ]; | 17 | ]; |
17 | homepage = "https://github.com/jtanguy/hmacaroons"; | 18 | homepage = "https://github.com/jtanguy/hmacaroons"; |
18 | description = "Haskell implementation of macaroons"; | 19 | description = "Haskell implementation of macaroons"; |
diff --git a/hmacaroons.cabal b/hmacaroons.cabal index 83b2cd7..85958b9 100644 --- a/hmacaroons.cabal +++ b/hmacaroons.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | name: hmacaroons | 1 | name: hmacaroons |
2 | version: 0.3.0.0 | 2 | version: 0.4.0.0 |
3 | synopsis: Haskell implementation of macaroons | 3 | synopsis: Haskell implementation of macaroons |
4 | description: | 4 | description: |
5 | Hmacaroons is a pure haskell implementation of macaroons. It aims to | 5 | Hmacaroons is a pure haskell implementation of macaroons. It aims to |
@@ -58,7 +58,7 @@ library | |||
58 | Crypto.Macaroon.Verifier.Internal | 58 | Crypto.Macaroon.Verifier.Internal |
59 | build-depends: base >=4 && < 5, | 59 | build-depends: base >=4 && < 5, |
60 | attoparsec >=0.12, | 60 | attoparsec >=0.12, |
61 | transformers >= 0.4, | 61 | transformers >= 0.3, |
62 | bytestring >=0.10, | 62 | bytestring >=0.10, |
63 | base64-bytestring >= 1.0, | 63 | base64-bytestring >= 1.0, |
64 | byteable >= 0.1 && <0.2, | 64 | byteable >= 0.1 && <0.2, |
@@ -110,4 +110,4 @@ test-suite test | |||
110 | tasty-quickcheck >= 0.8, | 110 | tasty-quickcheck >= 0.8, |
111 | QuickCheck >= 2.8, | 111 | QuickCheck >= 2.8, |
112 | deepseq >= 1.1, | 112 | deepseq >= 1.1, |
113 | transformers >= 0.4 | 113 | transformers >= 0.3 |
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) |
diff --git a/test/Crypto/Macaroon/Instances.hs b/test/Crypto/Macaroon/Instances.hs index 6348c56..019c094 100644 --- a/test/Crypto/Macaroon/Instances.hs +++ b/test/Crypto/Macaroon/Instances.hs | |||
@@ -11,6 +11,7 @@ This test suite is based on the pymacaroons test suite: | |||
11 | -} | 11 | -} |
12 | module Crypto.Macaroon.Instances where | 12 | module Crypto.Macaroon.Instances where |
13 | 13 | ||
14 | import Control.Applicative | ||
14 | import Control.Monad | 15 | import Control.Monad |
15 | import Data.Byteable | 16 | import Data.Byteable |
16 | import qualified Data.ByteString as BS | 17 | import qualified Data.ByteString as BS |