Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: haskell
ghc:
- "8.2"
- "8.0"
2 changes: 1 addition & 1 deletion Flatr-App-Core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ executable Flatr-App-Core-exe
, word8
, bytestring
, base16-bytestring >=0.1
, cryptohash >=0.11
, cryptonite >=0.24
default-language: Haskell2010

source-repository head
Expand Down
4 changes: 2 additions & 2 deletions Flatr-App-Core.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ mkDerivation, aeson, base, base16-bytestring, bytestring
, configurator, containers, cryptohash, http-types
, configurator, containers, cryptonite, http-types
, hvect, jwt, monad-logger, mtl, persistent, persistent-sqlite
, persistent-template, random, Spock, stdenv, text, time
, transformers, word8, iso8601-time
Expand All @@ -16,7 +16,7 @@ mkDerivation {
libraryHaskellDepends = [ base ];
executableHaskellDepends = [
aeson base base16-bytestring bytestring configurator containers
cryptohash http-types hvect jwt monad-logger mtl persistent
cryptonite http-types hvect jwt monad-logger mtl persistent
persistent-sqlite persistent-template random Spock text time
transformers word8 iso8601-time

Expand Down
6 changes: 4 additions & 2 deletions app/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module Util where
import Control.Arrow
import Control.Monad.IO.Class
import Control.Monad.Logger (LoggingT, runStdoutLoggingT)
import qualified Crypto.Hash.SHA512 as SHA
import qualified Crypto.KDF.Argon2 as Ar2
import Crypto.Error (throwCryptoError)
import Data.Aeson hiding (json)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Base16 as B16
Expand Down Expand Up @@ -42,7 +43,8 @@ decodeHex = fst . B16.decode . E.encodeUtf8

hashPassword :: T.Text -> BS.ByteString -> T.Text
hashPassword password salt =
makeHex . SHA.finalize $ SHA.updates SHA.init [salt, E.encodeUtf8 password]
makeHex . throwCryptoError $ Ar2.hash Ar2.defaultOptions (E.encodeUtf8 password) salt 1024
-- throwCryptoError can in theory throw, crashing the program. But this will happen only if salt length or output size are invalid. As this will never be the case (as long as we provide acceptable salts), this will never happen.

runSQL
:: (HasSpock m, SpockConn m ~ SqlBackend)
Expand Down