Skip to content

Commit

Permalink
fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Mar 27, 2024
1 parent a89cbb0 commit cc4e51f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/io/otoroshi/wasm4s/scaladsl/wasm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ object WasmSourceKind {
ec: ExecutionContext
): Future[Either[JsValue, ByteString]] = {
ic.wasmoSettings.flatMap {
case Some(settings @ WasmoSettings(url, _, _, kind, _)) => {
case Some(settings @ WasmoSettings(url, _, _, kind, _, tlsConfig)) => {
val (apikeyHeader, apikey) = ApikeyHelper.generate(settings)
val wasmoUrl = s"$url/wasm/$path"
val followRedirect = opts.select("follow_redirect").asOpt[Boolean].getOrElse(true)
val timeout = opts.select("timeout").asOpt[Long].map(_.millis).getOrElse(5.seconds)
if (ic.logger.isDebugEnabled) ic.logger.debug(s"[WasmSourceKind Wasmo] fetching wasm from source at GET ${wasmoUrl}")
ic.url(wasmoUrl)
ic.url(wasmoUrl, tlsConfig)
.withFollowRedirects(followRedirect)
.withRequestTimeout(timeout)
.withHttpHeaders(
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/io/otoroshi/wasm4s/scaladsl/wasmo.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.otoroshi.wasm4s.scaladsl

import io.otoroshi.wasm4s.scaladsl.implicits._
import io.otoroshi.wasm4s.scaladsl.security.TlsConfig
import play.api.libs.json._

import scala.util.{Failure, Success, Try}
Expand All @@ -11,6 +12,7 @@ case class WasmoSettings(
clientSecret: String = "admin-api-apikey-secret",
pluginsFilter: Option[String] = Some("*"),
legacyAuth: Boolean = false,
tlsConfig: Option[TlsConfig] = None,
) {
def json: JsValue = WasmoSettings.format.writes(this)
}
Expand All @@ -24,6 +26,7 @@ object WasmoSettings {
"clientSecret" -> o.clientSecret,
"legacyAuth" -> o.legacyAuth,
"pluginsFilter" -> o.pluginsFilter.map(JsString).getOrElse(JsNull).as[JsValue],
"tlsConfig" -> o.tlsConfig.map(_.json).getOrElse(JsNull).as[JsValue],
)

override def reads(json: JsValue): JsResult[WasmoSettings] =
Expand All @@ -34,6 +37,7 @@ object WasmoSettings {
clientSecret = (json \ "clientSecret").asOpt[String].getOrElse("admin-api-apikey-secret"),
legacyAuth = (json \ "legacyAuth").asOpt[Boolean].getOrElse(false),
pluginsFilter = (json \ "pluginsFilter").asOpt[String].getOrElse("*").some,
tlsConfig = json.select("tls").asOpt(TlsConfig.format).orElse(json.select("tls_config").asOpt(TlsConfig.format))
)
} match {
case Failure(e) => JsError(e.getMessage)
Expand Down

0 comments on commit cc4e51f

Please sign in to comment.