From 7001a61e8fa105cd51715e471d0a682bf23528fd Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Wed, 6 May 2015 11:15:04 +0200 Subject: Nixify package & documentation Added quickcheck helper --- .travis.yml | 1 + CONTRIBUTING.md | 26 ++++++++++++++++ default.nix | 20 +++++++++++++ hmacaroons.cabal | 62 +++++++++++++++++++++++++++++++++++---- shell.nix | 8 +++++ test/Crypto/Macaroon/Instances.hs | 6 ++++ 6 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 default.nix create mode 100644 shell.nix 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 @@ +How to contribute +================= +First and most important: Submit issues ! + +If you want to contribute, please fork the repo, and send us a pull request with +your changes. + +Tests and cabal flags +--------------------- +For this project we use the standard hunit/quickcheck tests. +If you want to submit a new feature, please try to integrate at least +*some* tests. + +Code style +---------- +We do not impose any specific style of code, but you can improve your code +by running it through `hlint`. + +Crypto analysis +--------------- +This library has **not** been audited by security experts ! +It relies on an existing implementation and crypto libraries. + +Any analysis is welcome, and I will gladly merge it. + + diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..10ee0b9 --- /dev/null +++ b/default.nix @@ -0,0 +1,20 @@ +{ mkDerivation, attoparsec, base, base64-bytestring, byteable +, bytestring, cereal, cipher-aes, cryptohash, deepseq, hex, stdenv +, tasty, tasty-hunit, tasty-quickcheck +}: +mkDerivation { + pname = "hmacaroons"; + version = "0.1.0.0"; + src = ./.; + buildDepends = [ + attoparsec base base64-bytestring byteable bytestring cereal + cipher-aes cryptohash deepseq hex + ]; + testDepends = [ + attoparsec base base64-bytestring byteable bytestring cereal + cryptohash hex tasty tasty-hunit tasty-quickcheck + ]; + homepage = "https://github.com/jtanguy/hmacaroons"; + description = "Haskell implementation of macaroons"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/hmacaroons.cabal b/hmacaroons.cabal index 2b23c89..5590af6 100644 --- a/hmacaroons.cabal +++ b/hmacaroons.cabal @@ -1,23 +1,73 @@ name: hmacaroons version: 0.1.0.0 synopsis: Haskell implementation of macaroons --- description: +description: + = Macaroons: Pure haskell implementation of macaroons + #macaroons-pure-haskell-implementation-of-macaroons# + + Macaroons is a pure haskell implementation of macaroons. It aims to + provide compatibility at a serialized level with the + and + the + + __WARNING: This library has not been audited by security experts.__ + __There is no error handling at the moment, everyhting is silently + accepted__ + + It is developed in the purpose of exploration purposes, and would need + much more attention if it were to be used in production. + + = References + #references# + + == Papers and articles + #papers-and-articles# + + - + - + - + + == Implementations + #implementations# + + - + - + - + - + - + + = TODO + #todo# + + - Third party caveats + - Verify Macaroons + - Discharge Macaroons + - JSON serialization + - Quickcheck tests + - Error handling + - FFI\'s for testing and benchmarking purposes license: BSD3 license-file: LICENSE author: Julien Tanguy maintainer: julien.tanguy@jhome.fr --- copyright: +homepage: https://github.com/jtanguy/hmacaroons +bug-reports: https://github.com/jtanguy/hmacaroons/issues category: Data build-type: Simple extra-source-files: README.md + CONTRIBUTING.md cabal-version: >=1.10 +source-repository head + type: git + branch: master + location: https://github.com/jtanguy/hmacaroons + library exposed-modules: Crypto.Macaroon, Crypto.Macaroon.Binder Crypto.Macaroon.Serializer.Base64 other-modules: Crypto.Macaroon.Internal - -- other-extensions: build-depends: base >=4 && < 5, attoparsec >=0.12, bytestring >=0.10, @@ -41,14 +91,14 @@ benchmark bench attoparsec >=0.12, bytestring >=0.10, base64-bytestring >= 1.0, + byteable >= 0.1 && <0.2, cereal >= 0.4, cryptohash >=0.11 && <0.12, - cipher-aes >=0.2 && <0.3, - byteable >= 0.1 && <0.2, +-- cipher-aes >=0.2 && <0.3, hex >= 0.1, deepseq >= 1.1, criterion >= 1.1 - + test-suite test default-language: Haskell2010 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 @@ +with (import {}).pkgs; +let hspkgs = haskell-ng.packages.ghc7101.override { + overrides = self: super: { + hmacaroons = self.callPackage ./. {}; + }; + }; +in + 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 import Crypto.Macaroon + +-- | Adjust the size parameter, by transforming it with the given +-- function. +scale :: (Int -> Int) -> Gen a -> Gen a +scale f g = sized (\n -> resize (f n) g) + newtype Url = Url { unUrl :: BS.ByteString } deriving (Show) instance Arbitrary Url where -- cgit v1.2.3