Skip to content

Commit

Permalink
WIP #555 - refactor secrets and test default password on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Jun 23, 2020
1 parent 016a8a8 commit 1f59b42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions otoroshi/app/env/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ class Env(val configuration: Configuration,
lazy val providerCssUrlHtml: Html =
providerCssUrl.map(url => Html(s"""<link href="$url" rel="stylesheet">""")).getOrElse(Html(""))

lazy val otoroshiSecret: String = configuration.getOptionalWithFileSupport[String]("otoroshi.secret").get

lazy val providerDashboardSecret: String =
configuration.getOptionalWithFileSupport[String]("otoroshi.provider.secret").getOrElse("secret")

Expand Down Expand Up @@ -559,6 +561,19 @@ class Env(val configuration: Configuration,
logger.info(s"Admin UI exposed on http://$backOfficeHost:$port")
}

if (otoroshiSecret == "VeryLongPasswordThatYouMustToOverwrite") {
logger.warn("#########################################")
logger.warn("#########################################")
logger.warn("BEWARE OF USING DEFAULT OTOROSHI SECRET !!!")
logger.warn("You are using the default value for the main otoroshi secret. It is used to sign various stuff including session cookies. " +
"You MUST change its value before deploying to production")
logger.warn("You can change configuration by passing otoroshi.secret at runtime (https://maif.github.io/otoroshi/manual/firstrun/configfile.html)")
logger.warn("You can change if from environment variable with name OTOROSHI_SECRET (https://maif.github.io/otoroshi/manual/firstrun/env.html)")
logger.warn("Beware of using default otoroshi secret")
logger.warn("#########################################")
logger.warn("#########################################")
}

lazy val datastores: DataStores = {
configuration.getOptionalWithFileSupport[String]("app.storage").getOrElse("redis") match {
case _ if clusterConfig.mode == ClusterMode.Worker =>
Expand Down
4 changes: 3 additions & 1 deletion otoroshi/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ otoroshi {
instance = ${app.instance}
maintenanceMode = false
maintenanceMode = ${?OTOROSHI_MAINTENANCE_MODE_ENABLED}
secret = "VeryLongPasswordThatYouMustToOverwrite"
secret = ${?OTOROSHI_SECRET}
options {
bypassUserRightsCheck = false
bypassUserRightsCheck = ${?OTOROSHI_OPTIONS_BYPASSUSERRIGHTSCHECK}
Expand All @@ -672,7 +674,7 @@ otoroshi {
staticExposedDomain = ${?OTOROSHI_OPTIONS_STATIC_EXPOSED_DOMAIN}
}
sessions {
secret = "8pqi0nU6p6srkH1rfJpMrNKEPMm4U6aBJd0zr5qAqs235WQRtVHCfTCLEzLW43yM"
secret = ${otoroshi.secret}
secret = ${?OTOROSHI_SESSIONS_SECRET}
}
cache {
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ play.server.https.engineProvider = ssl.DynamicSSLEngineProvider
# play.server.https.keyStoreDumpPath = "./otoroshi.jks"
play.server.https.keyStoreDumpPath = ${?HTTPS_KEYSTORE_DUMP_PATH}

play.http.secret.key = "sca4ujJ6NmTOinW60f+F2kPYZL5pzJrZj5gvsLAPPqI="
play.http.secret.key = ${otoroshi.secret}
play.http.secret.key = ${?PLAY_CRYPTO_SECRET}

play.server.http.idleTimeout = 60s
Expand Down

0 comments on commit 1f59b42

Please sign in to comment.