Skip to content

Commit

Permalink
Use pureconfig for invoker/scheduler's basic http auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed May 27, 2022
1 parent 1e09049 commit 202637e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ invoker:
{% endif %}"
extraEnv: "{{ invoker_extraEnv | default({}) }}"
protocol: "{{ invoker_protocol | default('https') }}"
username: "{{ invoker_username | default('invoker.user') }}"
password: "{{ invoker_password | default('invoker.pass') }}"
ssl:
cn: "openwhisk-invokers"
keyPrefix: "{{ __invoker_ssl_keyPrefix }}"
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/invoker/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@
"CONFIG_whisk_containerPool_prewarmExpirationCheckIntervalVariance": "{{ container_pool_prewarm_expirationCheckIntervalVariance | default('10 seconds') }}"
"CONFIG_whisk_containerPool_prewarmPromotion": "{{ container_pool_strict | default('false') | lower }}"
"CONFIG_whisk_containerPool_prewarmMaxRetryLimit": "{{ container_pool_prewarm_max_retry_limit | default(5) }}"
"CONFIG_whisk_invoker_username": "{{ invoker.username }}"
"CONFIG_whisk_invoker_password": "{{ invoker.password }}"

- name: extend invoker dns env
set_fact:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,10 @@ object ConfigKeys {
val whiskClusterName = "whisk.cluster.name"

val dataManagementServiceRetryInterval = "whisk.scheduler.data-management-service.retry-interval"

val whiskSchedulerUsername = "whisk.scheduler.username"
val whiskSchedulerPassword = "whisk.scheduler.password"

val whiskInvokerUsername = "whisk.invoker.username"
val whiskInvokerPassword = "whisk.invoker.password"
}
2 changes: 2 additions & 0 deletions core/invoker/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ whisk {
}

invoker {
username: "invoker.user"
password: "invoker.pass"
protocol: http
}
runtime.delete.timeout = "30 seconds"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.BasicHttpCredentials
import akka.http.scaladsl.server.Route
import org.apache.openwhisk.common.{Logging, TransactionId}
import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.http.BasicRasService
import org.apache.openwhisk.http.ErrorResponse.terminate
import pureconfig.loadConfigOrThrow
import spray.json.PrettyPrinter

import scala.concurrent.ExecutionContext
Expand Down Expand Up @@ -57,9 +59,8 @@ class DefaultInvokerServer(val invoker: InvokerCore, systemUsername: String, sys

object DefaultInvokerServer extends InvokerServerProvider {

// TODO: TBD, after FPCInvokerReactive is ready, can read the credentials from pureconfig
val invokerUsername = "admin"
val invokerPassword = "admin"
private val invokerUsername = loadConfigOrThrow[String](ConfigKeys.whiskInvokerUsername)
private val invokerPassword = loadConfigOrThrow[String](ConfigKeys.whiskInvokerPassword)

override def instance(
invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.BasicHttpCredentials
import akka.http.scaladsl.server.Route
import org.apache.openwhisk.common.{Logging, TransactionId}
import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.http.BasicRasService
import org.apache.openwhisk.http.ErrorResponse.terminate
import pureconfig.loadConfigOrThrow
import spray.json.PrettyPrinter

import scala.concurrent.ExecutionContext
Expand Down Expand Up @@ -57,9 +59,8 @@ class FPCInvokerServer(val invoker: InvokerCore, systemUsername: String, systemP

object FPCInvokerServer extends InvokerServerProvider {

// TODO: TBD, after FPCInvokerReactive is ready, can read the credentials from pureconfig
val invokerUsername = "admin"
val invokerPassword = "admin"
private val invokerUsername = loadConfigOrThrow[String](ConfigKeys.whiskInvokerUsername)
private val invokerPassword = loadConfigOrThrow[String](ConfigKeys.whiskInvokerPassword)

override def instance(
invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.BasicHttpCredentials
import akka.http.scaladsl.server.Route
import org.apache.openwhisk.common.{Logging, TransactionId}
import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.http.BasicRasService
import org.apache.openwhisk.http.ErrorResponse.terminate
import pureconfig.loadConfigOrThrow
import spray.json.DefaultJsonProtocol._
import spray.json._

Expand Down Expand Up @@ -75,11 +77,9 @@ class FPCSchedulerServer(scheduler: SchedulerCore, systemUsername: String, syste

object FPCSchedulerServer {

// TODO: TBD, after FPCScheduler is ready, can read the credentials from pureconfig
val schedulerUsername = "admin"
val schedulerPassword = "admin"

val queuePathPrefix = "queue"
private val schedulerUsername = loadConfigOrThrow[String](ConfigKeys.whiskSchedulerUsername)
private val schedulerPassword = loadConfigOrThrow[String](ConfigKeys.whiskSchedulerPassword)
private val queuePathPrefix = "queue"

def instance(scheduler: SchedulerCore)(implicit ec: ExecutionContext,
actorSystem: ActorSystem,
Expand Down

0 comments on commit 202637e

Please sign in to comment.