This is an automated email from the ASF dual-hosted git repository.
markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new e96c1bb Introduce SPI to be able to support different authentication
directives. (#3829)
e96c1bb is described below
commit e96c1bbd5a0f54c923f0153116f7c1f165275e94
Author: Martin Henke
AuthorDate: Mon Jul 16 11:01:00 2018 +0200
Introduce SPI to be able to support different authentication directives.
(#3829)
---
ansible/group_vars/all | 2 +
ansible/roles/controller/tasks/deploy.yml | 1 +
common/scala/src/main/resources/reference.conf | 1 +
.../whisk/core/controller/AuthenticatedRoute.scala | 29
...te.scala => BasicAuthenticationDirective.scala} | 54 +-
.../scala/whisk/core/controller/RestAPIs.scala | 47 +++
...ateTests.scala => BasicAuthenticateTests.scala} | 46 +-
7 files changed, 98 insertions(+), 82 deletions(-)
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index dc5d942..729a683 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -78,6 +78,8 @@ controller:
seedNodes: "{{ groups['controllers'] | map('extract', hostvars,
'ansible_host') | list }}"
loadbalancer:
spi: "{{ controller_loadbalancer_spi | default('') }}"
+ authentication:
+spi: "{{ controller_authentication_spi | default('') }}"
loglevel: "{{ controller_loglevel | default(whisk_loglevel) |
default('INFO') }}"
entitlement:
spi: "{{ controller_entitlement_spi | default('') }}"
diff --git a/ansible/roles/controller/tasks/deploy.yml
b/ansible/roles/controller/tasks/deploy.yml
index e4b0885..990c18c 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -233,6 +233,7 @@
"{{ controller.loadbalancer.spi }}"
"CONFIG_whisk_spi_EntitlementSpiProvider": "{{
controller.entitlement.spi }}"
+ "CONFIG_whisk_spi_AuthenticationDirectiveProvider": "{{
controller.authentication.spi }}"
"CONFIG_logback_log_level": "{{ controller.loglevel }}"
"CONFIG_whisk_transactions_header": "{{ transactions.header }}"
diff --git a/common/scala/src/main/resources/reference.conf
b/common/scala/src/main/resources/reference.conf
index b658f87..2f2d898 100644
--- a/common/scala/src/main/resources/reference.conf
+++ b/common/scala/src/main/resources/reference.conf
@@ -9,6 +9,7 @@ whisk.spi {
LogStoreProvider =
whisk.core.containerpool.logging.DockerToActivationLogStoreProvider
LoadBalancerProvider = whisk.core.loadBalancer.ShardingContainerPoolBalancer
EntitlementSpiProvider = whisk.core.entitlement.LocalEntitlementProvider
+ AuthenticationDirectiveProvider =
whisk.core.controller.BasicAuthenticationDirective
}
dispatchers {
diff --git
a/core/controller/src/main/scala/whisk/core/controller/AuthenticatedRoute.scala
b/core/controller/src/main/scala/whisk/core/controller/AuthenticatedRoute.scala
index 69a63f4..295dc89 100644
---
a/core/controller/src/main/scala/whisk/core/controller/AuthenticatedRoute.scala
+++
b/core/controller/src/main/scala/whisk/core/controller/AuthenticatedRoute.scala
@@ -17,40 +17,11 @@
package whisk.core.controller
-import scala.concurrent.ExecutionContext
-import scala.concurrent.Future
-
import akka.http.scaladsl.server.Route
-import akka.http.scaladsl.server.Directives._
-import akka.http.scaladsl.model.headers.BasicHttpCredentials
-import akka.http.scaladsl.server.directives._
-import akka.http.scaladsl.server.directives.AuthenticationResult
-import akka.http.scaladsl.model.headers._
import whisk.common.TransactionId
import whisk.core.entity.Identity
-/** A common trait for secured routes */
-trait AuthenticatedRoute {
-
- /** An execution context for futures */
- protected implicit val executionContext: ExecutionContext
-
- /** Creates HTTP BasicAuth handler */
- def basicAuth[A](verify: Option[BasicHttpCredentials] => Future[Option[A]])
= {
-authenticateOrRejectWithChallenge[BasicHttpCredentials, A] { creds =>
- verify(creds).map {
-case Some(t) => AuthenticationResult.success(t)
-case None=>
AuthenticationResult.failWithChallenge(HttpChallenges.basic("OpenWhisk secure
realm"))
- }
-}
- }
-
- /** Validates credentials against database of subjects */
- protected def validateCredentials(credentials: Option[BasicHttpCredentials])(
-implicit transid: TransactionId): Future[Option[Identity]]
-}
-
/** A trait for authenticated routes. */
trait AuthenticatedRouteProvider {
def routes(user: Identity)(implicit transid: TransactionId): Route
diff --git
a/core/controller/src/main/scala/whisk/core/controller/Authenticate.scala
b/core/controller/src/main/scala/whisk/core/controller/BasicAuthenticationDirective.scala
similarity in