aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Crypto/Macaroon.hs
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 18:04:05 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 18:04:05 +0200
commit1971e224efa6a5940fb8b15c718f2b59c2d0f014 (patch)
treec57e8c4784f8318c26edc3336ad94d757be6e79c /src/Crypto/Macaroon.hs
parent2aede11ad7e5addd50cd4e3c202e094319e942f2 (diff)
downloadhmacaroons-1971e224efa6a5940fb8b15c718f2b59c2d0f014.tar.gz
hmacaroons-1971e224efa6a5940fb8b15c718f2b59c2d0f014.tar.zst
hmacaroons-1971e224efa6a5940fb8b15c718f2b59c2d0f014.zip
Documentation
Diffstat (limited to 'src/Crypto/Macaroon.hs')
-rw-r--r--src/Crypto/Macaroon.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Crypto/Macaroon.hs b/src/Crypto/Macaroon.hs
index 42e4a07..07043f7 100644
--- a/src/Crypto/Macaroon.hs
+++ b/src/Crypto/Macaroon.hs
@@ -25,6 +25,7 @@ module Crypto.Macaroon (
25 , Caveat 25 , Caveat
26 , Key 26 , Key
27 , Location 27 , Location
28 , Sig
28 -- * Accessing functions 29 -- * Accessing functions
29 -- ** Macaroons 30 -- ** Macaroons
30 , location 31 , location
@@ -65,18 +66,23 @@ create secret ident loc = MkMacaroon loc ident [] (toBytes (hmac derivedKey iden
65 where 66 where
66 derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256) 67 derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256)
67 68
69-- | Caveat target location
68caveatLoc :: Caveat -> Location 70caveatLoc :: Caveat -> Location
69caveatLoc = cl 71caveatLoc = cl
70 72
73-- | Caveat identifier
71caveatId :: Caveat -> Key 74caveatId :: Caveat -> Key
72caveatId = cid 75caveatId = cid
73 76
77-- | Caveat verification identifier
74caveatVId :: Caveat -> Key 78caveatVId :: Caveat -> Key
75caveatVId = vid 79caveatVId = vid
76 80
81-- | Inspect a macaroon's contents. For debugging purposes.
77inspect :: Macaroon -> String 82inspect :: Macaroon -> String
78inspect = show 83inspect = show
79 84
85-- | Serialize a macaroon in an URL-safe Base64 encoding
80serialize :: Macaroon -> BS.ByteString 86serialize :: Macaroon -> BS.ByteString
81serialize m = B8.filter (/= '=') . B64.encode $ packets 87serialize m = B8.filter (/= '=') . B64.encode $ packets
82 where 88 where