password-instances-3.0.0.0: typeclass instances for password package
Copyright(c) Dennis Gosnell 2019; Felix Paulusma 2020
LicenseBSD-style (see LICENSE file)
Maintainercdep.illabout@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Data.Password.Instances

Description

This module provides additional typeclass instances for Password and PasswordHash.

See the Data.Password.Types module for more information.

Orphan instances

(TypeError (ErrMsg "JSON") :: Constraint) => ToJSON Password Source #

Type error! Do not use toJSON on a Password!

Instance details

FromJSON Password Source #

This instance allows a Password to be created from a JSON blob.

>>> let maybePassword = decode "\"foobar\"" :: Maybe Password
>>> fmap unsafeShowPassword maybePassword
Just "foobar"

There is no instance for ToJSON for Password because we don't want to accidentally encode a plain-text Password to JSON and send it to the end-user.

Similarly, there is no ToJSON and FromJSON instance for PasswordHash because we don't want to accidentally send the password hash to the end user.

Instance details

(TypeError (ErrMsg "HttpApiData") :: Constraint) => ToHttpApiData Password Source #

Type error! Do not transmit plain-text Passwords over HTTP!

Instance details

FromHttpApiData Password Source #

This instance allows a Password to be created with functions like parseUrlPiece or parseQueryParam.

>>> let eitherPassword = parseUrlPiece "foobar"
>>> fmap unsafeShowPassword eitherPassword
Right "foobar"
Instance details

(TypeError (ErrMsg "PersistValue") :: Constraint) => PersistField Password Source #

Type error! Do not store plain-text Passwords in your database!

Instance details

PersistFieldSql (PasswordHash a) Source #

This instance allows a PasswordHash to be stored as a field in an SQL database in Database.Persist.Sql.

Instance details

PersistField (PasswordHash a) Source #

This instance allows a PasswordHash to be stored as a field in a database using Database.Persist.

>>> let salt = Salt "abcdefghijklmnop"
>>> let pass = mkPassword "foobar"
>>> let hashedPassword = hashPasswordWithSalt 10 salt pass
>>> toPersistValue hashedPassword
PersistText "$2b$10$WUHhXETkX0fnYkrqZU3ta.N8Utt4U77kW4RVbchzgvBvBBEEdCD/u"

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 Password, because we don't want to make it easy to store a plain-text password in the database.

Instance details