haveibeenpwned 0.2.0.0 → 0.2.0.1
raw patch · 3 files changed
+74/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- README.md +68/−0
- haveibeenpwned.cabal +2/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for haveibeenpwned +## 0.2.0.1++* Add readme to extra-source-files so that it appears on hackage+ ## 0.2.0.0 * Breaking change in order to make the API and the implementation more secure.
+ README.md view
@@ -0,0 +1,68 @@+haveibeenpwned+<img align="right" src="https://obsidian.systems/static/images/ObsidianSystemsLogo.svg">+======================+[](https://haskell.org) [](https://hackage.haskell.org/package/haveibeenpwned) [](https://matrix.hackage.haskell.org/#/package/haveibeenpwned) [](https://github.com/obsidiansystems/haveibeenpwned/actions) [](https://travis-ci.org/obsidiansystems/haveibeenpwned) [](https://github.com/obsidiansystems/haveibeenpwned/blob/master/LICENSE)++A [haskell](https://haskell.org) library for checking passwords against the+[haveibeenpwned.com](https://haveibeenpwned.com) database.++By means of this library you can do some basic strength check on new user+passwords. Common weak passwords like many plain English words or also many+stronger passwords which happen to have been leaked will likely be found in the+database and can thus be rejected.++Example+-------++The example below can be built and run using `cabal build exe:readme` or `cabal+repl exe:readme`.++```haskell ++> {-# LANGUAGE OverloadedStrings #-}+>+> import Control.Monad.IO.Class (liftIO)+> import Control.Monad.Logger (runStdoutLoggingT)+> import Control.Exception (bracket_)+> import Data.Text as T (pack)+> import Network.HTTP.Client (newManager)+> import Network.HTTP.Client.TLS (tlsManagerSettings)+> import System.IO (hFlush, stdout, hGetEcho, stdin, hSetEcho)+>+> import HaveIBeenPwned+>+> -- | A really simple demo of the hibp functionality. Asks the user to enter+> -- a password and then uses the hibp api to check whether that password has+> -- been pwned.+> consoleHaveIBeenPwned :: IO ()+> consoleHaveIBeenPwned = do+> runStdoutLoggingT $ do+> mgr <- liftIO $ newManager tlsManagerSettings+> p <- liftIO $ getPassword+> let hibpEnv = HaveIBeenPwnedConfig mgr "https://api.pwnedpasswords.com/range"+> p' <- flip runPwnedT hibpEnv $ haveIBeenPwned $ T.pack p+> liftIO $ case p' of+> HaveIBeenPwnedResult_Secure ->+> putStrLn "Your password does not appear in any known breaches. Practice good password hygene."+> HaveIBeenPwnedResult_Pwned p'' ->+> putStrLn $ "You have been pwned! Your password has appeared in breaches " ++ show p'' ++ " times."+> HaveIBeenPwnedResult_Error ->+> putStrLn "Network Error, try again later"+>+> getPassword :: IO String+> getPassword = do+> putStr "Password: "+> hFlush stdout+> password <- withEcho False getLine+> putChar '\n'+> return password+>+> withEcho :: Bool -> IO a -> IO a+> withEcho echo action = do+> old <- hGetEcho stdin+> bracket_ (hSetEcho stdin echo) (hSetEcho stdin old) action+>+> main :: IO ()+> main = consoleHaveIBeenPwned++```
haveibeenpwned.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: haveibeenpwned-version: 0.2.0.0+version: 0.2.0.1 synopsis: Library for checking for weak/compromised passwords. description: This library uses the haveibeenpwned database to check for weak or compromised passwords.@@ -13,6 +13,7 @@ copyright: 2019 Obsidian Systems LLC category: Web extra-source-files: CHANGELOG.md+ README.md tested-with: GHC ==8.6.5 || ==8.8.4 library