Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pureconfig for invoker/scheduler's basic http auth #5252

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an equivalent default config for the scheduler?

Also don't know off the top of my head but is . a special character for curl requests? Wouldn't want to make it harder to curl the invoker with a special character for those that don't care about creds and just using the default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scheduler already has such config https://github.com/apache/openwhisk/blob/master/core/scheduler/src/main/resources/application.conf#L62-L63

and . is not special for curl:

[raja@localhost ansible]$ curl -u invoker.user:invoker.pass https://localhost:12001/isEnabled -k
{"enabled":true}

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