password-instances (empty) → 0.1.0.0
raw patch · 8 files changed
+214/−0 lines, 8 filesdep +QuickCheckdep +aesondep +basesetup-changed
Dependencies added: QuickCheck, aeson, base, doctest, password, password-instances, persistent, quickcheck-instances
Files
- ChangeLog.md +6/−0
- LICENSE +30/−0
- README.md +10/−0
- Setup.hs +2/−0
- password-instances.cabal +71/−0
- src/Data/Password/Instances.hs +86/−0
- test/doctest/doctest.hs +7/−0
- test/tasty/Spec.hs +2/−0
+ ChangeLog.md view
@@ -0,0 +1,6 @@+# Changelog for password-instances++## 0.1.0.0++- Initial version.+
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Dennis Gosnell (c) 2019++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Dennis Gosnell nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,10 @@+# password-instances++[](http://travis-ci.org/cdepillabout/password)+[](https://hackage.haskell.org/package/password-instances)+[](http://stackage.org/lts/package/password-instances)+[](http://stackage.org/nightly/package/password-instances)+[](./LICENSE)++This package provides various typeclass instances for the plain-text password+and hashed password datatypes from the [password](../password) package.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ password-instances.cabal view
@@ -0,0 +1,71 @@+cabal-version: 1.12++name: password-instances+version: 0.1.0.0+category: Data+synopsis: typeclass instances for password package+description: A library providing typeclass instances for common libraries for the types from the password package.+homepage: https://github.com/cdepillabout/password/password-instances#readme+bug-reports: https://github.com/cdepillabout/password/issues+author: Dennis Gosnell+maintainer: cdep.illabout@gmail.com+copyright: Copyright (c) 2019 Dennis Gosnell+license: BSD3+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++source-repository head+ type: git+ location: https://github.com/cdepillabout/password++library+ hs-source-dirs:+ src+ exposed-modules:+ Data.Password.Instances+ other-modules:+ Paths_password_instances+ build-depends:+ base >=4.7 && <5+ , aeson+ , password+ , persistent+ ghc-options:+ -Wall+ default-language:+ Haskell2010++test-suite password-instances-doctest+ type:+ exitcode-stdio-1.0+ hs-source-dirs:+ test/doctest+ main-is:+ doctest.hs+ ghc-options:+ -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.7 && <5+ , doctest+ , QuickCheck+ , quickcheck-instances+ default-language:+ Haskell2010++test-suite password-instances-tasty+ type:+ exitcode-stdio-1.0+ hs-source-dirs:+ test/tasty+ main-is:+ Spec.hs+ ghc-options:+ -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.7 && <5+ , password-instances+ default-language:+ Haskell2010
+ src/Data/Password/Instances.hs view
@@ -0,0 +1,86 @@+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE InstanceSigs #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module : Data.Password.Instances+Copyright : (c) Dennis Gosnell, 2019+License : BSD-style (see LICENSE file)+Maintainer : cdep.illabout@gmail.com+Stability : experimental+Portability : POSIX++This module provides the same interface as "Data.Password", but it also+provides additional typeclass instances for 'Pass' and 'PassHash'.++See the "Data.Password" module for more information.+-}++module Data.Password.Instances+ (+ -- * Plaintext Password+ Pass(..)+ -- * Hashed Password+ , PassHash(..)+ , Salt(..)+ -- * Functions for Hashing Plaintext Passwords+ , hashPass+ , hashPassWithSalt+ , newSalt+ -- * Functions for Checking Plaintext Passwords Against Hashed Passwords+ , checkPass+ , PassCheck(..)+ -- * Unsafe Debugging Functions for Showing a Password+ , unsafeShowPassword+ , unsafeShowPasswordText+ , -- * Setup for doctests.+ -- $setup+ ) where++import Data.Aeson (FromJSON)+import Data.Password+import Database.Persist.Class (PersistField)+++-- $setup+-- >>> :set -XOverloadedStrings+--+-- Import needed functions.+--+-- >>> import Data.Aeson (decode)+-- >>> import Database.Persist.Class (PersistField(toPersistValue))+++-- | This instance allows a 'Pass' to be created from a JSON blob.+--+-- >>> let maybePass = decode "\"foobar\"" :: Maybe Pass+-- >>> fmap unsafeShowPassword maybePass+-- Just "foobar"+--+-- There is no instance for 'ToJSON' for 'Pass' because we don't want to+-- accidentally encode a plain-text 'Pass' to JSON and send it to the end-user.+--+-- Similarly, there is no 'ToJSON' and 'FromJSON' instance for 'PassHash'+-- because we don't want to accidentally send the password hash to the end+-- user.+deriving newtype instance FromJSON Pass++-- | This instance allows a 'PassHash' to be stored as a field in a database using+-- "Database.Persist".+--+-- >>> let salt = Salt "abcdefghijklmnopqrstuvwxyz012345"+-- >>> let pass = Pass "foobar"+-- >>> let hashedPassword = hashPassWithSalt (Pass "foobar") salt+-- >>> toPersistValue hashedPassword+-- PersistText "14|8|1|YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU=|nENDaqWBmPKapAqQ3//H0iBImweGjoTqn5SvBS8Mc9FPFbzq6w65maYPZaO+SPamVZRXQjARQ8Y+5rhuDhjIhw=="+--+-- In the example above, the long 'PersistText' will be the value you store in+-- the database.+--+-- We don't provide an instance of 'PersistField' for 'Pass', because we don't+-- want to make it easy to store a plain-text password in the database.+deriving newtype instance PersistField PassHash
+ test/doctest/doctest.hs view
@@ -0,0 +1,7 @@++module Main (main) where++import Test.DocTest++main :: IO ()+main = doctest ["src"]
+ test/tasty/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"