Skip to content
Snippets Groups Projects
Commit 7c7015f8 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

fixed deprecations

parent 6a414ee0
Branches
No related tags found
No related merge requests found
......@@ -60,7 +60,7 @@ class AuthController @Inject()(system: ActorSystem,
}
def logout = Action { _ =>
val prefix = configuration.getString("play.http.context").getOrElse("/")
val prefix = configuration.getOptional[String]("play.http.context").getOrElse("/")
Redirect(s"${prefix}login").withNewSession
}
......
......@@ -5,7 +5,7 @@ import play.api.Configuration
trait AuthConfig {
def getSetting(setting: String)(implicit config: Configuration) = {
config.getString(setting).getOrElse(throw MissingSettingException(setting))
config.getOptional[String](setting).getOrElse(throw MissingSettingException(setting))
}
}
......@@ -17,7 +17,7 @@ trait AuthenticationModule {
@Singleton
class AuthenticationModuleImpl @Inject()(config: Configuration) extends AuthenticationModule {
val service = config.getString("auth.type") match {
val service = config.getOptional[String]("auth.type") match {
case Some("ldap") => Some(new LDAPAuthService(config))
case Some("basic") => Some(new BasicAuthService(config))
case _ => None
......
......@@ -6,7 +6,7 @@ import play.api.Configuration
class BasicAuthService @Inject()(globalConfig: Configuration) extends AuthService {
private implicit final val config = new BasicAuthConfig(globalConfig.getConfig("auth.settings").get)
private implicit final val config = new BasicAuthConfig(globalConfig.get[Configuration]("auth.settings"))
def auth(username: String, password: String): Option[String] = {
(username, password) match {
......
......@@ -14,7 +14,7 @@ class LDAPAuthService @Inject()(globalConfig: Configuration) extends AuthService
private val log = org.slf4j.LoggerFactory.getLogger(classOf[LDAPAuthService])
private final val config = new LDAPAuthConfig(globalConfig.getConfig("auth.settings").get)
private final val config = new LDAPAuthConfig(globalConfig.get[Configuration]("auth.settings"))
def auth(username: String, password: String): Option[String] = {
val env = new Hashtable[String, String](11)
......
......@@ -5,8 +5,8 @@ import java.util.Date
import com.google.inject.{ImplementedBy, Inject}
import play.api.Configuration
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.driver.SQLiteDriver.api._
import slick.jdbc.JdbcProfile
import slick.jdbc.SQLiteProfile.api._
import slick.lifted.TableQuery
import scala.concurrent.ExecutionContext.Implicits.global
......@@ -28,7 +28,7 @@ trait RestHistoryDAO {
class RestHistoryDAOImpl @Inject()(dbConfigProvider: DatabaseConfigProvider,
config: Configuration) extends RestHistoryDAO {
private val max = config.getInt("rest.history.size").getOrElse(50)
private val max = config.getOptional[Int]("rest.history.size").getOrElse(50)
private val dbConfig = dbConfigProvider.get[JdbcProfile]
......
......@@ -3,7 +3,7 @@ package dao
import java.security.MessageDigest
import java.util.Date
import slick.driver.SQLiteDriver.api._
import slick.jdbc.SQLiteProfile.api._
import slick.lifted.Tag
case class HashedRestRequest(path: String, method: String, body: String, username: String, createdAt: Long, md5: String)
......
......@@ -322,7 +322,7 @@ class HTTPElasticClient @Inject()(client: WSClient) extends ElasticClient {
val authentication = target.authentication
val url = s"${target.host.replaceAll("/+$", "")}$uri"
val request =
authentication.foldLeft(client.url(url).withMethod(method).withHeaders(headers: _*)) {
authentication.foldLeft(client.url(url).withMethod(method).withHttpHeaders(headers: _*)) {
case (request, auth) =>
request.withAuth(auth.username, auth.password, WSAuthScheme.BASIC)
}
......
......@@ -5,6 +5,10 @@ import javax.inject.Singleton
import com.google.inject.{ImplementedBy, Inject}
import play.api.Configuration
import scala.collection.JavaConverters._
import scala.util.{Failure, Success, Try}
@ImplementedBy(classOf[HostsImpl])
trait Hosts {
......@@ -17,18 +21,18 @@ trait Hosts {
@Singleton
class HostsImpl @Inject()(config: Configuration) extends Hosts {
val hosts: Map[String, ElasticServer] = config.getConfigSeq("hosts") match {
case Some(hostsConf) => hostsConf.map { hostConf =>
val host = hostConf.getString("host").get
val name = hostConf.getString("name").getOrElse(host)
val username = hostConf.getString("auth.username")
val password = hostConf.getString("auth.password")
val hosts: Map[String, ElasticServer] = Try(config.underlying.getConfigList("hosts").asScala.map(Configuration(_))) match {
case Success(hostsConf) => hostsConf.map { hostConf =>
val host = hostConf.getOptional[String]("host").get
val name = hostConf.getOptional[String]("name").getOrElse(host)
val username = hostConf.getOptional[String]("auth.username")
val password = hostConf.getOptional[String]("auth.password")
(username, password) match {
case (Some(username), Some(password)) => (name -> ElasticServer(host, Some(ESAuth(username, password))))
case _ => (name -> ElasticServer(host, None))
}
}.toMap
case _ => Map()
case Failure(_) => Map()
}
def getHostNames() = hosts.keys.toSeq
......
# Secret key
secret = "changeme"
play.crypto.secret = ${secret}
play.http.secret.key = ${secret}
es {
gzip = false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment