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

fixed deprecations

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