diff options
author | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-05-06 11:15:04 +0200 |
---|---|---|
committer | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-05-06 11:15:04 +0200 |
commit | 7001a61e8fa105cd51715e471d0a682bf23528fd (patch) | |
tree | 2ee75ab9a5959baa23db6fd9b60c63aa610ada13 | |
parent | a22bcdb648d1f540ae895cb246997dcdcce7b568 (diff) | |
download | hmacaroons-7001a61e8fa105cd51715e471d0a682bf23528fd.tar.gz hmacaroons-7001a61e8fa105cd51715e471d0a682bf23528fd.tar.zst hmacaroons-7001a61e8fa105cd51715e471d0a682bf23528fd.zip |
Nixify package & documentation
Added quickcheck helper
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | CONTRIBUTING.md | 26 | ||||
-rw-r--r-- | default.nix | 20 | ||||
-rw-r--r-- | hmacaroons.cabal | 62 | ||||
-rw-r--r-- | shell.nix | 8 | ||||
-rw-r--r-- | test/Crypto/Macaroon/Instances.hs | 6 |
6 files changed, 117 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..999bd37 --- /dev/null +++ b/.travis.yml | |||
@@ -0,0 +1 @@ | |||
language: haskell | |||
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3e85b0b --- /dev/null +++ b/CONTRIBUTING.md | |||
@@ -0,0 +1,26 @@ | |||
1 | How to contribute | ||
2 | ================= | ||
3 | First and most important: Submit issues ! | ||
4 | |||
5 | If you want to contribute, please fork the repo, and send us a pull request with | ||
6 | your changes. | ||
7 | |||
8 | Tests and cabal flags | ||
9 | --------------------- | ||
10 | For this project we use the standard hunit/quickcheck tests. | ||
11 | If you want to submit a new feature, please try to integrate at least | ||
12 | *some* tests. | ||
13 | |||
14 | Code style | ||
15 | ---------- | ||
16 | We do not impose any specific style of code, but you can improve your code | ||
17 | by running it through `hlint`. | ||
18 | |||
19 | Crypto analysis | ||
20 | --------------- | ||
21 | This library has **not** been audited by security experts ! | ||
22 | It relies on an existing implementation and crypto libraries. | ||
23 | |||
24 | Any analysis is welcome, and I will gladly merge it. | ||
25 | |||
26 | |||
diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..10ee0b9 --- /dev/null +++ b/default.nix | |||
@@ -0,0 +1,20 @@ | |||
1 | { mkDerivation, attoparsec, base, base64-bytestring, byteable | ||
2 | , bytestring, cereal, cipher-aes, cryptohash, deepseq, hex, stdenv | ||
3 | , tasty, tasty-hunit, tasty-quickcheck | ||
4 | }: | ||
5 | mkDerivation { | ||
6 | pname = "hmacaroons"; | ||
7 | version = "0.1.0.0"; | ||
8 | src = ./.; | ||
9 | buildDepends = [ | ||
10 | attoparsec base base64-bytestring byteable bytestring cereal | ||
11 | cipher-aes cryptohash deepseq hex | ||
12 | ]; | ||
13 | testDepends = [ | ||
14 | attoparsec base base64-bytestring byteable bytestring cereal | ||
15 | cryptohash hex tasty tasty-hunit tasty-quickcheck | ||
16 | ]; | ||
17 | homepage = "https://github.com/jtanguy/hmacaroons"; | ||
18 | description = "Haskell implementation of macaroons"; | ||
19 | license = stdenv.lib.licenses.bsd3; | ||
20 | } | ||
diff --git a/hmacaroons.cabal b/hmacaroons.cabal index 2b23c89..5590af6 100644 --- a/hmacaroons.cabal +++ b/hmacaroons.cabal | |||
@@ -1,23 +1,73 @@ | |||
1 | name: hmacaroons | 1 | name: hmacaroons |
2 | version: 0.1.0.0 | 2 | version: 0.1.0.0 |
3 | synopsis: Haskell implementation of macaroons | 3 | synopsis: Haskell implementation of macaroons |
4 | -- description: | 4 | description: |
5 | = Macaroons: Pure haskell implementation of macaroons | ||
6 | #macaroons-pure-haskell-implementation-of-macaroons# | ||
7 | |||
8 | Macaroons is a pure haskell implementation of macaroons. It aims to | ||
9 | provide compatibility at a serialized level with the | ||
10 | <https://github.com/rescrv/libmacaroons reference implementation> and | ||
11 | the <https://github.com/ecordell/pymacaroons python implementation> | ||
12 | |||
13 | __WARNING: This library has not been audited by security experts.__ | ||
14 | __There is no error handling at the moment, everyhting is silently | ||
15 | accepted__ | ||
16 | |||
17 | It is developed in the purpose of exploration purposes, and would need | ||
18 | much more attention if it were to be used in production. | ||
19 | |||
20 | = References | ||
21 | #references# | ||
22 | |||
23 | == Papers and articles | ||
24 | #papers-and-articles# | ||
25 | |||
26 | - <http://research.google.com/pubs/pub41892.html Google paper on macaroons> | ||
27 | - <https://air.mozilla.org/macaroons-cookies-with-contextual-caveats-for-decentralized-authorization-in-the-cloud/ Macaroons at Mozilla> | ||
28 | - <http://hackingdistributed.com/2014/11/23/macaroons-in-hyperdex/ Time for better security in NoSQL> | ||
29 | |||
30 | == Implementations | ||
31 | #implementations# | ||
32 | |||
33 | - <https://github.com/rescrv/libmacaroons C> | ||
34 | - <https://github.com/nitram509/jmacaroons Java> | ||
35 | - <https://github.com/nitram509/macaroons.js Node.js> | ||
36 | - <https://github.com/ecordell/pymacaroons Python> | ||
37 | - <https://github.com/cryptosphere/rust-macaroons.git Rust> | ||
38 | |||
39 | = TODO | ||
40 | #todo# | ||
41 | |||
42 | - Third party caveats | ||
43 | - Verify Macaroons | ||
44 | - Discharge Macaroons | ||
45 | - JSON serialization | ||
46 | - Quickcheck tests | ||
47 | - Error handling | ||
48 | - FFI\'s for testing and benchmarking purposes | ||
5 | license: BSD3 | 49 | license: BSD3 |
6 | license-file: LICENSE | 50 | license-file: LICENSE |
7 | author: Julien Tanguy | 51 | author: Julien Tanguy |
8 | maintainer: julien.tanguy@jhome.fr | 52 | maintainer: julien.tanguy@jhome.fr |
9 | -- copyright: | 53 | homepage: https://github.com/jtanguy/hmacaroons |
54 | bug-reports: https://github.com/jtanguy/hmacaroons/issues | ||
10 | category: Data | 55 | category: Data |
11 | build-type: Simple | 56 | build-type: Simple |
12 | extra-source-files: README.md | 57 | extra-source-files: README.md |
58 | CONTRIBUTING.md | ||
13 | cabal-version: >=1.10 | 59 | cabal-version: >=1.10 |
14 | 60 | ||
61 | source-repository head | ||
62 | type: git | ||
63 | branch: master | ||
64 | location: https://github.com/jtanguy/hmacaroons | ||
65 | |||
15 | library | 66 | library |
16 | exposed-modules: Crypto.Macaroon, | 67 | exposed-modules: Crypto.Macaroon, |
17 | Crypto.Macaroon.Binder | 68 | Crypto.Macaroon.Binder |
18 | Crypto.Macaroon.Serializer.Base64 | 69 | Crypto.Macaroon.Serializer.Base64 |
19 | other-modules: Crypto.Macaroon.Internal | 70 | other-modules: Crypto.Macaroon.Internal |
20 | -- other-extensions: | ||
21 | build-depends: base >=4 && < 5, | 71 | build-depends: base >=4 && < 5, |
22 | attoparsec >=0.12, | 72 | attoparsec >=0.12, |
23 | bytestring >=0.10, | 73 | bytestring >=0.10, |
@@ -41,14 +91,14 @@ benchmark bench | |||
41 | attoparsec >=0.12, | 91 | attoparsec >=0.12, |
42 | bytestring >=0.10, | 92 | bytestring >=0.10, |
43 | base64-bytestring >= 1.0, | 93 | base64-bytestring >= 1.0, |
94 | byteable >= 0.1 && <0.2, | ||
44 | cereal >= 0.4, | 95 | cereal >= 0.4, |
45 | cryptohash >=0.11 && <0.12, | 96 | cryptohash >=0.11 && <0.12, |
46 | cipher-aes >=0.2 && <0.3, | 97 | -- cipher-aes >=0.2 && <0.3, |
47 | byteable >= 0.1 && <0.2, | ||
48 | hex >= 0.1, | 98 | hex >= 0.1, |
49 | deepseq >= 1.1, | 99 | deepseq >= 1.1, |
50 | criterion >= 1.1 | 100 | criterion >= 1.1 |
51 | 101 | ||
52 | test-suite test | 102 | test-suite test |
53 | default-language: Haskell2010 | 103 | default-language: Haskell2010 |
54 | type: exitcode-stdio-1.0 | 104 | type: exitcode-stdio-1.0 |
diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..07952fc --- /dev/null +++ b/shell.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | with (import <nixpkgs> {}).pkgs; | ||
2 | let hspkgs = haskell-ng.packages.ghc7101.override { | ||
3 | overrides = self: super: { | ||
4 | hmacaroons = self.callPackage ./. {}; | ||
5 | }; | ||
6 | }; | ||
7 | in | ||
8 | hspkgs.hmacaroons.env | ||
diff --git a/test/Crypto/Macaroon/Instances.hs b/test/Crypto/Macaroon/Instances.hs index 5d4b062..4e2f39f 100644 --- a/test/Crypto/Macaroon/Instances.hs +++ b/test/Crypto/Macaroon/Instances.hs | |||
@@ -23,6 +23,12 @@ import Test.Tasty.QuickCheck | |||
23 | 23 | ||
24 | import Crypto.Macaroon | 24 | import Crypto.Macaroon |
25 | 25 | ||
26 | |||
27 | -- | Adjust the size parameter, by transforming it with the given | ||
28 | -- function. | ||
29 | scale :: (Int -> Int) -> Gen a -> Gen a | ||
30 | scale f g = sized (\n -> resize (f n) g) | ||
31 | |||
26 | newtype Url = Url { unUrl :: BS.ByteString } deriving (Show) | 32 | newtype Url = Url { unUrl :: BS.ByteString } deriving (Show) |
27 | 33 | ||
28 | instance Arbitrary Url where | 34 | instance Arbitrary Url where |