aboutsummaryrefslogtreecommitdiffhomepage
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
parentcb1ee5df44a6a68f32e7f8413cee4a7105d37b4b (diff)
downloadhmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.tar.gz
hmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.tar.zst
hmacaroons-a11f20be0fadf21cc96164b49305b59ac7445aa2.zip
ghc<7.10.1 compat
-rw-r--r--default.nix5
-rw-r--r--hmacaroons.cabal6
-rw-r--r--src/Crypto/Macaroon/Verifier.hs6
-rw-r--r--src/Crypto/Macaroon/Verifier/Internal.hs2
-rw-r--r--test/Crypto/Macaroon/Instances.hs1
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}:
5mkDerivation { 5mkDerivation {
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 @@
1name: hmacaroons 1name: hmacaroons
2version: 0.3.0.0 2version: 0.4.0.0
3synopsis: Haskell implementation of macaroons 3synopsis: Haskell implementation of macaroons
4description: 4description:
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
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)
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-}
12module Crypto.Macaroon.Instances where 12module Crypto.Macaroon.Instances where
13 13
14import Control.Applicative
14import Control.Monad 15import Control.Monad
15import Data.Byteable 16import Data.Byteable
16import qualified Data.ByteString as BS 17import qualified Data.ByteString as BS