You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/08/31 16:06:43 UTC

[GitHub] rabbah commented on a change in pull request #3661: Restrict allowed namespaces when creating action of certain kinds

rabbah commented on a change in pull request #3661: Restrict allowed namespaces when creating action of certain kinds
URL: https://github.com/apache/incubator-openwhisk/pull/3661#discussion_r214402534
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/entitlement/KindRestrictor.scala
 ##########
 @@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.core.entitlement
+
+import whisk.common.Logging
+import whisk.common.TransactionId
+import whisk.core.ConfigKeys
+import whisk.core.entity.{Exec, Identity}
+import pureconfig.loadConfigOrThrow
+
+/**
+ * Restrict allowed kinds via provided whitelists
+ *
+ * @param whitelist set of default allowed kinds when not explicitly available via namespace limits
+ */
+protected[core] case class DefaultAllowedKinds(whitelist: Option[Set[String]] = None)
+
+/**
+ * A class for determining whether a given namespace is allowed to contain a given kind.
+ *
+ * @param allowedKinds a default set of allowed kinds
+ */
+class KindRestrictor(allowedKinds: DefaultAllowedKinds = loadConfigOrThrow[DefaultAllowedKinds](ConfigKeys.runtimes))(
+  implicit logging: Logging) {
+
+  logging.info(this, s"allowedKinds = $allowedKinds")(TransactionId.controller)
+
+  private def execKindAllowed(exec: Option[Exec], kinds: Set[String]): Boolean = {
+    exec.map(e => kinds.contains(e.kind)).getOrElse(false)
+  }
+
+  /**
+   * Checks whether a given kind is allowed for a given user.
+   */
+  def check(user: Identity, exec: Option[Exec])(implicit tid: TransactionId): Boolean = {
 
 Review comment:
   the whitelist != the list of runtime kinds specified in the manifest?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services