# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
#
# This must be changed for production, but we recommend not changing it in this file.
#
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
play.http.secret.key = "changeme"
play.http.secret.key = ${?PLAY_HTTP_SECRET_KEY}
play.http.parser.maxMemoryBuffer = 370K
# The application languages
# ~~~~~
play.i18n.langs = [ "en" ]

# See https://www.playframework.com/documentation/2.8.x/AllowedHostsFilter for more details.
# Note: allowed = ["."] matches all hosts hence would not be recommended in a production environment.
play.filters.hosts {
  allowed = ["."]
}

# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# play.http.router = my.application.Routes

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.username=sa
# db.default.password=""

# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=false

# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false

portal.vinyldns.backend.url = "http://localhost:9000"
portal.vinyldns.backend.url = ${?VINYLDNS_BACKEND_URL}

portal.vinyldns.url = "http://localhost:9001"
portal.vinyldns.url = ${?VINYLDNS_PORTAL_URL}

portal.test_login = true
portal.test_login = ${?TEST_LOGIN}

mysql {
  class-name = "vinyldns.mysql.repository.MySqlDataStoreProvider"
  endpoint = "localhost:19002"
  endpoint = ${?MYSQL_ENDPOINT}

  settings {
    # JDBC Settings, these are all values in scalikejdbc-config, not our own
    # these must be overridden to use MYSQL for production use
    # assumes a docker or mysql instance running locally
    name = "vinyldns"
    name = ${?DATABASE_NAME}
    driver = "org.mariadb.jdbc.Driver"
    driver = ${?JDBC_DRIVER}
    migration-url = "jdbc:mariadb://"${mysql.endpoint}"/?user=root&password=pass"
    migration-url = ${?JDBC_MIGRATION_URL}
    url = "jdbc:mariadb://"${mysql.endpoint}"/vinyldns?user=root&password=pass"
    url = ${?JDBC_URL}
    user = "root"
    user = ${?JDBC_USER}
    password = "pass"
    password = ${?JDBC_PASSWORD}
    flyway-out-of-order = false
    flyway-out-of-order = ${?FLYWAY_OUT_OF_ORDER}
  }

  repositories {
    # override with any repos that are running in mysql
    user {}
    user-change {}
    task {}
  }
}


LDAP {
  user = "test"
  user = ${?LDAP_USER}
  password = "test"
  password = ${?LDAP_PASSWORD}
  domain = "test"
  domain = ${?LDAP_DOMAIN}

  searchBase = [
    # override with a list of domains:
    # { organization = "someDomain", domainName = "DC=test,DC=test,DC=com" }
  ]

  context {
    initialContextFactory = "com.sun.jndi.ldap.LdapCtxFactory"
    initialContextFactory = ${?LDAP_CONTEXT_FACTORY}
    securityAuthentication = "simple"
    securityAuthentication = ${?LDAP_SECURITY}
    providerUrl = "ldaps://somedomain.com:9999"
    providerUrl = ${?LDAP_PROVIDER_URL}
  }

}

play.filters.enabled += "filters.AccessLoggingFilter"

// Expire session after 10 hours
play.http.session.maxAge = 10h
play.http.session.maxAge = ${?SESSION_MAX_AGE}

// session secure should be false in order to run properly locally, this is set properly on deployment
play.http.session.secure = false
play.http.session.secure = ${?SESSION_SECURE}

play.http.session.httpOnly = true
play.http.session.httpOnly = ${?SESSION_HTTP_ONLY}

// MUST be the same as the API!!!
crypto {
  type = "vinyldns.core.crypto.NoOpCrypto"
  type = ${?CRYPTO_TYPE}
  secret = ${?CRYPTO_SECRET}
}

http.port = 9000
http.port = ${?PORTAL_PORT}

links = [
  {
    displayOnSidebar = true
    displayOnLoginScreen = true
    title = "API Documentation"
    href = "http://vinyldns.io"
    icon = "fa fa-file-text-o"
  }
]

dns-change-notices = [
  {
    status = "Complete"
    alertType = "info"
    text = "Your changes are fully implemented. Keep in mind it may take a few hours for the changes to fully propogate out."
  },
  {
    status = "PendingReview"
    alertType = "info"
    text = "Your DNS Change requires further review. It will be approved and processed following the review."
    hrefText = "See the docs for more information."
    href = "https://www.vinyldns.io/portal/manual-review-scheduling"
  },
  {
    status = "Scheduled"
    alertType = "info"
    text = "If there are any changes in your scheduled DNS Change with a status of Needs Review they will be addressed prior to the scheduled date and time."
  }
]

play.modules.enabled += "modules.VinylDNSModule"

# base version this image is built on
vinyldns.base-version = "unset"
vinyldns.version = ${vinyldns.base-version} # default to the base version if not overridden
vinyldns.version = ${?VINYLDNS_VERSION} # can override via an environment varaible

// Local.conf has files specific to your environment, for example your own LDAP settings
include "local.conf"
