From 86f3882318d323d1920ca1c7da6e816f0ed376da Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Mon, 17 Aug 2015 17:38:24 +0200 Subject: Change verifier api and split Verifier module - Added haddocks --- src/Crypto/Macaroon.hs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/Crypto/Macaroon.hs') diff --git a/src/Crypto/Macaroon.hs b/src/Crypto/Macaroon.hs index bfcf8df..c9c8c21 100644 --- a/src/Crypto/Macaroon.hs +++ b/src/Crypto/Macaroon.hs @@ -23,6 +23,7 @@ module Crypto.Macaroon ( -- * Types Macaroon , Caveat + , Secret , Key , Location , Sig @@ -33,9 +34,9 @@ module Crypto.Macaroon ( , caveats , signature -- ** Caveats - , caveatLoc - , caveatId - , caveatVId + , cl + , cid + , vid -- * Create Macaroons , create @@ -54,23 +55,11 @@ import qualified Data.ByteString.Char8 as B8 import Crypto.Macaroon.Internal -- | Create a Macaroon from its key, identifier and location -create :: Key -> Key -> Location -> Macaroon +create :: Secret -> Key -> Location -> Macaroon create secret ident loc = MkMacaroon loc ident [] (toBytes (hmac derivedKey ident :: HMAC SHA256)) where derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256) --- | Caveat target location -caveatLoc :: Caveat -> Location -caveatLoc = cl - --- | Caveat identifier -caveatId :: Caveat -> Key -caveatId = cid - --- | Caveat verification identifier -caveatVId :: Caveat -> Key -caveatVId = vid - -- | Inspect a macaroon's contents. For debugging purposes. inspect :: Macaroon -> String inspect = show -- cgit v1.2.3 From 27d5a3a43c7d736f8cd842f14f3178d532de9152 Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Mon, 17 Aug 2015 19:39:05 +0200 Subject: Modify exports & haddock --- src/Crypto/Macaroon.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Crypto/Macaroon.hs') diff --git a/src/Crypto/Macaroon.hs b/src/Crypto/Macaroon.hs index c9c8c21..86d8eb7 100644 --- a/src/Crypto/Macaroon.hs +++ b/src/Crypto/Macaroon.hs @@ -43,16 +43,20 @@ module Crypto.Macaroon ( , inspect , addFirstPartyCaveat -- , addThirdPartyCaveat + -- * Serialize + , module Crypto.Macaroon.Serializer.Base64 + -- * Verify + , module Crypto.Macaroon.Verifier ) where -- import Crypto.Cipher.AES import Crypto.Hash import Data.Byteable -import qualified Data.ByteString as BS -import qualified Data.ByteString.Base64.URL as B64 -import qualified Data.ByteString.Char8 as B8 +import qualified Data.ByteString as BS import Crypto.Macaroon.Internal +import Crypto.Macaroon.Serializer.Base64 +import Crypto.Macaroon.Verifier -- | Create a Macaroon from its key, identifier and location create :: Secret -> Key -> Location -> Macaroon @@ -78,5 +82,3 @@ addFirstPartyCaveat ident m = addCaveat (location m) ident BS.empty m -- addThirdPartyCaveat key cid loc m = addCaveat loc cid vid m -- where -- vid = encryptECB (initAES (signature m)) key - - -- cgit v1.2.3