Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
198
Issues
198
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
cb654969
Commit
cb654969
authored
May 19, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SECURITY] Prod mode preserves confidentiality of passwords now. (Use Dev for debug only).
parent
7c50b9de
Pipeline
#856
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
Main.hs
bin/gargantext-server/Main.hs
+3
-8
API.hs
src/Gargantext/API.hs
+13
-7
No files found.
bin/gargantext-server/Main.hs
View file @
cb654969
...
...
@@ -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
...
...
src/Gargantext/API.hs
View file @
cb654969
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment