Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains functions specific to the pgcrypto module
Documentation
data HashAlgorithm Source #
pgcrypto hashing algorithms see: https://www.postgresql.org/docs/current/pgcrypto.html
bf
and xdes
algorithms have an optional iterations count parameter. All limitations and considerations
mentioned in the pgcrypto
module documentation regarding iteration count apply. It is possible to supply
an invalid iteration count, which will lead to an sql error.
Requires the pgcrypto module.
Instances
Eq HashAlgorithm Source # | |
Defined in Database.Esqueleto.PostgreSQL.Pgcrypto (==) :: HashAlgorithm -> HashAlgorithm -> Bool # (/=) :: HashAlgorithm -> HashAlgorithm -> Bool # | |
Show HashAlgorithm Source # | |
Defined in Database.Esqueleto.PostgreSQL.Pgcrypto showsPrec :: Int -> HashAlgorithm -> ShowS # show :: HashAlgorithm -> String # showList :: [HashAlgorithm] -> ShowS # |
toCrypt :: SqlString s => HashAlgorithm -> s -> SqlExpr (Value s) Source #
(crypt()
) Calculate a crypt-like hash from the provided password
Requires the pgcrypto module.
WARNING: Using toCrypt
may leak sensitive data via logging. Filtering logs in production environments
when using toCrypt
, such as using filterLogger
on `monad-logger` based stacks is highly advised.
example:
share [mkPersist sqlSettings] [persistLowerCase| UserAccount json name T.Text UniqueName name passwordHash T.Text deriving Show Read Eq insertSelect $ do pure $ UserAccount <# val "username" & toCrypt (BF Nothing) "1234password"
fromCrypt :: SqlString s => SqlExpr (Value s) -> s -> SqlExpr (Value Bool) Source #
(crypt()
) Retrieve a hashed password
Requires the pgcrypto module.
example:
share [mkPersist sqlSettings] [persistLowerCase| UserAccount json name T.Text UniqueName name passwordHash T.Text deriving Show Read Eq login name pwd = select $ do user <- from $ Table UserAccount where_ $ user ^. UserAccountName ==. val name &&. fromCrypt (user ^. UserAccountPasswordHash) pwd pure user