]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Auth.hs
change export
[gargantext.git] / src / Gargantext / Core / Auth.hs
1 {-|
2 Module : Gargantext.API.Admin.Auth.Check
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12
13 module Gargantext.Core.Auth ( createPasswordHash
14 , checkPassword
15 , module Data.Password.Argon2
16 )
17 where
18
19 import Control.Monad.IO.Class (MonadIO)
20 import Data.Text (Text)
21 import Data.Password.Argon2 hiding (checkPassword)
22 import qualified Data.Password.Argon2 as A
23
24
25 createPasswordHash :: MonadIO m
26 => Text
27 -> m (PasswordHash Argon2)
28 createPasswordHash x = hashPassword (mkPassword x)
29
30
31 checkPassword :: Password
32 -> PasswordHash Argon2
33 -> PasswordCheck
34 checkPassword = A.checkPassword
35
36 {-
37 -- Notes to implement Raw Password with argon2 lib
38 -- (now using password library, which does not use salt anymore)
39 -- import Crypto.Argon2 as Crypto
40 -- import Data.ByteString.Base64.URL as URL
41 -- import Data.Either
42 -- import Data.ByteString (ByteString)
43 secret_key :: ByteString
44 secret_key = "WRV5ymit8s~ge6%08dLR7Q!gBcpb1MY%7e67db2206"
45
46 type SecretKey = ByteString
47
48 hashNode :: SecretKey -> NodeToHash -> ByteString
49 hashNode sk (NodeToHash nt ni) = case hashResult of
50 Left e -> panic (cs $ show e)
51 Right h -> URL.encode h
52 where
53 hashResult = Crypto.hash Crypto.defaultHashOptions
54 sk
55 (cs $ show nt <> show ni)
56 -}