Commit cb654969 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[SECURITY] Prod mode preserves confidentiality of passwords now. (Use Dev for debug only).

parent 7c50b9de
Pipeline #856 failed with stage
......@@ -29,7 +29,7 @@ import Options.Generic
import System.Exit (exitSuccess)
import Gargantext.Prelude
import Gargantext.API (startGargantext) -- , startGargantextMock)
import Gargantext.API (startGargantext, Mode(..)) -- , startGargantextMock)
--------------------------------------------------------
-- Graph Tests
......@@ -39,13 +39,10 @@ import Gargantext.API (startGargantext) -- , startGargantextMock)
--import qualified Gargantext.Graph.Distances.Matrice as M
--------------------------------------------------------
data Mode = Dev | Mock | Prod
deriving (Show, Read, Generic)
instance ParseRecord Mode
instance ParseField Mode
instance ParseFields Mode
data MyOptions w =
MyOptions { run :: w ::: Mode
<?> "Possible modes: Dev | Mock | Prod"
......@@ -78,14 +75,12 @@ main = do
Nothing -> 8008
let start = case myMode of
Prod -> startGargantext myPort' (unpack myIniFile')
Mock -> panic "[ERROR] Mock mode unsupported"
_ -> startGargantext myMode myPort' (unpack myIniFile')
where
myIniFile' = case myIniFile of
Nothing -> panic "[ERROR] gargantext.ini needed"
Just i -> i
Dev -> panic "[ERROR] Dev mode unsupported"
Mock -> panic "[ERROR] Mock mode unsupported"
-- _ -> startGargantextMock myPort'
putStrLn $ "Starting with " <> show myMode <> " mode."
start
......
......@@ -59,7 +59,7 @@ import Data.Text.Encoding (encodeUtf8)
import Data.Validity
import Data.Version (showVersion)
import GHC.Base (Applicative)
import GHC.Generics (D1, Meta (..), Rep)
import GHC.Generics (D1, Meta (..), Rep, Generic)
import GHC.TypeLits (AppendSymbol, Symbol)
import Gargantext.API.Admin.Auth (AuthContext, auth)
import Gargantext.API.Admin.FrontEnd (frontEndServer)
......@@ -85,13 +85,17 @@ import qualified Data.Text.IO as T
import qualified Paths_gargantext as PG -- cabal magic build module
data Mode = Dev | Mock | Prod
deriving (Show, Read, Generic)
-- | startGargantext takes as parameters port number and Ini file.
startGargantext :: PortNumber -> FilePath -> IO ()
startGargantext port file = do
startGargantext :: Mode -> PortNumber -> FilePath -> IO ()
startGargantext mode port file = do
env <- newEnv port file
portRouteInfo port
app <- makeApp env
mid <- makeDevMiddleware
mid <- makeDevMiddleware mode
run port (mid app) `finally` stopGargantext env
portRouteInfo :: PortNumber -> IO ()
......@@ -183,8 +187,8 @@ makeMockApp env = do
-}
makeDevMiddleware :: IO Middleware
makeDevMiddleware = do
makeDevMiddleware :: Mode -> IO Middleware
makeDevMiddleware mode = do
-- logWare <- mkRequestLogger def { destination = RequestLogger.Logger $ env^.logger }
--logWare <- mkRequestLogger def { destination = RequestLogger.Logger "/tmp/logs.txt" }
......@@ -212,7 +216,9 @@ makeDevMiddleware = do
-- $ Warp.defaultSettings
--pure (warpS, logWare . checkOriginAndHost . corsMiddleware)
pure $ logStdoutDev . corsMiddleware
case mode of
Prod -> pure $ logStdout . corsMiddleware
_ -> pure $ logStdoutDev . corsMiddleware
---------------------------------------------------------------------
-- | API Global
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment