diff options
author | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-08-17 17:38:24 +0200 |
---|---|---|
committer | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-08-17 17:39:31 +0200 |
commit | 86f3882318d323d1920ca1c7da6e816f0ed376da (patch) | |
tree | 0e16232125c2fb6c0413d654e6b1537c9813b301 /src/Crypto/Macaroon.hs | |
parent | bf31e29028a4402ea0d2deefdb3b86efd526acd0 (diff) | |
download | hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.tar.gz hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.tar.zst hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.zip |
Change verifier api and split Verifier module
- Added haddocks
Diffstat (limited to 'src/Crypto/Macaroon.hs')
-rw-r--r-- | src/Crypto/Macaroon.hs | 21 |
1 files changed, 5 insertions, 16 deletions
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 ( | |||
23 | -- * Types | 23 | -- * Types |
24 | Macaroon | 24 | Macaroon |
25 | , Caveat | 25 | , Caveat |
26 | , Secret | ||
26 | , Key | 27 | , Key |
27 | , Location | 28 | , Location |
28 | , Sig | 29 | , Sig |
@@ -33,9 +34,9 @@ module Crypto.Macaroon ( | |||
33 | , caveats | 34 | , caveats |
34 | , signature | 35 | , signature |
35 | -- ** Caveats | 36 | -- ** Caveats |
36 | , caveatLoc | 37 | , cl |
37 | , caveatId | 38 | , cid |
38 | , caveatVId | 39 | , vid |
39 | 40 | ||
40 | -- * Create Macaroons | 41 | -- * Create Macaroons |
41 | , create | 42 | , create |
@@ -54,23 +55,11 @@ import qualified Data.ByteString.Char8 as B8 | |||
54 | import Crypto.Macaroon.Internal | 55 | import Crypto.Macaroon.Internal |
55 | 56 | ||
56 | -- | Create a Macaroon from its key, identifier and location | 57 | -- | Create a Macaroon from its key, identifier and location |
57 | create :: Key -> Key -> Location -> Macaroon | 58 | create :: Secret -> Key -> Location -> Macaroon |
58 | create secret ident loc = MkMacaroon loc ident [] (toBytes (hmac derivedKey ident :: HMAC SHA256)) | 59 | create secret ident loc = MkMacaroon loc ident [] (toBytes (hmac derivedKey ident :: HMAC SHA256)) |
59 | where | 60 | where |
60 | derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256) | 61 | derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256) |
61 | 62 | ||
62 | -- | Caveat target location | ||
63 | caveatLoc :: Caveat -> Location | ||
64 | caveatLoc = cl | ||
65 | |||
66 | -- | Caveat identifier | ||
67 | caveatId :: Caveat -> Key | ||
68 | caveatId = cid | ||
69 | |||
70 | -- | Caveat verification identifier | ||
71 | caveatVId :: Caveat -> Key | ||
72 | caveatVId = vid | ||
73 | |||
74 | -- | Inspect a macaroon's contents. For debugging purposes. | 63 | -- | Inspect a macaroon's contents. For debugging purposes. |
75 | inspect :: Macaroon -> String | 64 | inspect :: Macaroon -> String |
76 | inspect = show | 65 | inspect = show |