rabbah 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_r149805454
##########
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 the entitlement should yield different rejection codes
(forbidden or not found) depending on the subject and their rights. There
should be tests for this.
----------------------------------------------------------------
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