Skip to content

Commit 0c4aab1

Browse files
Use pureconfig for invoker/scheduler's basic http auth (#5252)
1 parent 1e09049 commit 0c4aab1

File tree

7 files changed

+25
-11
lines changed

7 files changed

+25
-11
lines changed

ansible/group_vars/all

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ invoker:
213213
{% endif %}"
214214
extraEnv: "{{ invoker_extraEnv | default({}) }}"
215215
protocol: "{{ invoker_protocol | default('https') }}"
216+
username: "{{ invoker_username | default('invoker.user') }}"
217+
password: "{{ invoker_password | default('invoker.pass') }}"
216218
ssl:
217219
cn: "openwhisk-invokers"
218220
keyPrefix: "{{ __invoker_ssl_keyPrefix }}"

ansible/roles/invoker/tasks/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@
287287
"CONFIG_whisk_containerPool_prewarmExpirationCheckIntervalVariance": "{{ container_pool_prewarm_expirationCheckIntervalVariance | default('10 seconds') }}"
288288
"CONFIG_whisk_containerPool_prewarmPromotion": "{{ container_pool_strict | default('false') | lower }}"
289289
"CONFIG_whisk_containerPool_prewarmMaxRetryLimit": "{{ container_pool_prewarm_max_retry_limit | default(5) }}"
290+
"CONFIG_whisk_invoker_username": "{{ invoker.username }}"
291+
"CONFIG_whisk_invoker_password": "{{ invoker.password }}"
290292

291293
- name: extend invoker dns env
292294
set_fact:

common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,10 @@ object ConfigKeys {
308308
val whiskClusterName = "whisk.cluster.name"
309309

310310
val dataManagementServiceRetryInterval = "whisk.scheduler.data-management-service.retry-interval"
311+
312+
val whiskSchedulerUsername = "whisk.scheduler.username"
313+
val whiskSchedulerPassword = "whisk.scheduler.password"
314+
315+
val whiskInvokerUsername = "whisk.invoker.username"
316+
val whiskInvokerPassword = "whisk.invoker.password"
311317
}

core/invoker/src/main/resources/application.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ whisk {
176176
}
177177

178178
invoker {
179+
username: "invoker.user"
180+
password: "invoker.pass"
179181
protocol: http
180182
}
181183
runtime.delete.timeout = "30 seconds"

core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/DefaultInvokerServer.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import akka.http.scaladsl.model.StatusCodes
2222
import akka.http.scaladsl.model.headers.BasicHttpCredentials
2323
import akka.http.scaladsl.server.Route
2424
import org.apache.openwhisk.common.{Logging, TransactionId}
25+
import org.apache.openwhisk.core.ConfigKeys
2526
import org.apache.openwhisk.http.BasicRasService
2627
import org.apache.openwhisk.http.ErrorResponse.terminate
28+
import pureconfig.loadConfigOrThrow
2729
import spray.json.PrettyPrinter
2830

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

5860
object DefaultInvokerServer extends InvokerServerProvider {
5961

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

6465
override def instance(
6566
invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService =

core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/FPCInvokerServer.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import akka.http.scaladsl.model.StatusCodes
2222
import akka.http.scaladsl.model.headers.BasicHttpCredentials
2323
import akka.http.scaladsl.server.Route
2424
import org.apache.openwhisk.common.{Logging, TransactionId}
25+
import org.apache.openwhisk.core.ConfigKeys
2526
import org.apache.openwhisk.http.BasicRasService
2627
import org.apache.openwhisk.http.ErrorResponse.terminate
28+
import pureconfig.loadConfigOrThrow
2729
import spray.json.PrettyPrinter
2830

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

5860
object FPCInvokerServer extends InvokerServerProvider {
5961

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

6465
override def instance(
6566
invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService =

core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/FPCSchedulerServer.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import akka.http.scaladsl.model.StatusCodes
2323
import akka.http.scaladsl.model.headers.BasicHttpCredentials
2424
import akka.http.scaladsl.server.Route
2525
import org.apache.openwhisk.common.{Logging, TransactionId}
26+
import org.apache.openwhisk.core.ConfigKeys
2627
import org.apache.openwhisk.http.BasicRasService
2728
import org.apache.openwhisk.http.ErrorResponse.terminate
29+
import pureconfig.loadConfigOrThrow
2830
import spray.json.DefaultJsonProtocol._
2931
import spray.json._
3032

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

7678
object FPCSchedulerServer {
7779

78-
// TODO: TBD, after FPCScheduler is ready, can read the credentials from pureconfig
79-
val schedulerUsername = "admin"
80-
val schedulerPassword = "admin"
81-
82-
val queuePathPrefix = "queue"
80+
private val schedulerUsername = loadConfigOrThrow[String](ConfigKeys.whiskSchedulerUsername)
81+
private val schedulerPassword = loadConfigOrThrow[String](ConfigKeys.whiskSchedulerPassword)
82+
private val queuePathPrefix = "queue"
8383

8484
def instance(scheduler: SchedulerCore)(implicit ec: ExecutionContext,
8585
actorSystem: ActorSystem,

0 commit comments

Comments
 (0)