tysonnorris commented on a change in pull request #4935:
URL: https://github.com/apache/openwhisk/pull/4935#discussion_r467296713
##########
File path:
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
##########
@@ -341,22 +349,69 @@ trait WhiskActionsApi extends WhiskCollectionAPI with
PostActionActivation with
override def fetch(user: Identity, entityName: FullyQualifiedEntityName,
env: Option[Parameters])(
implicit transid: TransactionId) = {
parameter('code ? true) { code =>
- code match {
- case true =>
- getEntity(WhiskAction.resolveActionAndMergeParameters(entityStore,
entityName), Some { action: WhiskAction =>
- val mergedAction = env map {
- action inherit _
- } getOrElse action
- complete(OK, mergedAction)
- })
- case false =>
-
getEntity(WhiskActionMetaData.resolveActionAndMergeParameters(entityStore,
entityName), Some {
- action: WhiskActionMetaData =>
- val mergedAction = env map {
- action inherit _
- } getOrElse action
- complete(OK, mergedAction)
- })
+ //check if execute only is enabled, and if there is a discrepancy
between the current user's namespace
+ //and that of the entity we are trying to fetch
+
+ if (executeOnly && user.namespace.name != entityName.namespace) {
+ terminate(Forbidden, forbiddenGetAction(entityName.path.asString))
+ } else {
+ code match {
+ case true =>
+ //Resolve Binding(Package) of the action
+ if (entityName.path.defaultPackage) {
+
getEntity(WhiskAction.resolveActionAndMergeParameters(entityStore, entityName),
Some {
+ action: WhiskAction =>
+ val mergedAction = env map {
+ action inherit _
+ } getOrElse action
+ complete(OK, mergedAction)
+ })
+ } else {
+ getEntity(
+ WhiskPackage.resolveBinding(entityStore,
entityName.path.toDocId, mergeParameters = true),
+ Some { pkg: WhiskPackage =>
+ val originalPackageLocation =
pkg.fullyQualifiedName(withVersion = false).namespace
+ if (executeOnly && originalPackageLocation !=
entityName.namespace) {
Review comment:
same - can you DRY this if line up?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]