mdeuser commented on a change in pull request #2877: Better error controller 
message for authorization failure
URL: 
https://github.com/apache/incubator-openwhisk/pull/2877#discussion_r146383888
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/controller/AuthorizedRouteDispatcher.scala
 ##########
 @@ -71,7 +74,21 @@ trait BasicAuthorizedRouteProvider extends Directives {
 
     onComplete(entitlementProvider.check(user, right, resource)) {
       case Success(_) => dispatchOp(user, right, resource)
-      case Failure(t) => handleEntitlementFailure(t)
+      case Failure(t) =>
+        t match {
+          case (r: RejectRequest) =>
+            r.code match {
+              case Forbidden =>
+                handleEntitlementFailure(
+                  RejectRequest(
+                    Forbidden,
+                    
Some(ErrorResponse(Messages.notAuthorizedtoAccessResource(resource.fqname), 
transid))))
+              case NotFound =>
+                handleEntitlementFailure(
+                  RejectRequest(NotFound, 
Some(ErrorResponse(Messages.resourceDoesntExist(resource.fqname), transid))))
+              case _ => handleEntitlementFailure(t)
+            }
+        }
 
 Review comment:
   @markusthoemmes - not sure i completely understand the question.  if a user 
does not have authority to access the targeted `namespace + entity` or 
`namespace + package + entity`, a forbidden response will be returned - even if 
the namespace does not exist.  from what i've seen, the target resource name 
displayed will be dependent on the resource being checked.  that value might be 
`ns/pkg` or `ns` or `ns/entity`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to