2 Module : Gargantext.API.Admin.Auth.Check
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE OverloadedStrings #-}
15 module Gargantext.Core.Auth ( createPasswordHash
17 , module Data.Password.Argon2
21 import Control.Monad.IO.Class (MonadIO)
22 import Data.Text (Text)
23 import Data.Password.Argon2 hiding (checkPassword)
24 import qualified Data.Password.Argon2 as A
27 createPasswordHash :: MonadIO m
29 -> m (PasswordHash Argon2)
30 createPasswordHash x = hashPassword (mkPassword x)
33 checkPassword :: Password
34 -> PasswordHash Argon2
36 checkPassword = A.checkPassword
39 -- Notes to implement Raw Password with argon2 lib
40 -- (now using password library, which does not use salt anymore)
41 -- import Crypto.Argon2 as Crypto
42 -- import Data.ByteString.Base64.URL as URL
44 -- import Data.ByteString (ByteString)
45 secret_key :: ByteString
46 secret_key = "WRV5ymit8s~ge6%08dLR7Q!gBcpb1MY%7e67db2206"
48 type SecretKey = ByteString
50 hashNode :: SecretKey -> NodeToHash -> ByteString
51 hashNode sk (NodeToHash nt ni) = case hashResult of
52 Left e -> panic (cs $ show e)
53 Right h -> URL.encode h
55 hashResult = Crypto.hash Crypto.defaultHashOptions
57 (cs $ show nt <> show ni)