]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Auth.hs
[CLEAN] Gexf instance in separate file.
[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 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE OverloadedStrings #-}
14
15 module Gargantext.Core.Auth ( createPasswordHash
16 , checkPassword
17 , module Data.Password.Argon2
18 )
19 where
20
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
25
26
27 createPasswordHash :: MonadIO m
28 => Text
29 -> m (PasswordHash Argon2)
30 createPasswordHash x = hashPassword (mkPassword x)
31
32
33 checkPassword :: Password
34 -> PasswordHash Argon2
35 -> PasswordCheck
36 checkPassword = A.checkPassword
37
38 {-
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
43 -- import Data.Either
44 -- import Data.ByteString (ByteString)
45 secret_key :: ByteString
46 secret_key = "WRV5ymit8s~ge6%08dLR7Q!gBcpb1MY%7e67db2206"
47
48 type SecretKey = ByteString
49
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
54 where
55 hashResult = Crypto.hash Crypto.defaultHashOptions
56 sk
57 (cs $ show nt <> show ni)
58 -}