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_r150641770
##########
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:
_thinking out loud_ to limit the amount of information giving to an
attacker, handing out a single response for either forbidden or not found seems
like a good way to avoid resource name discovery.
----------------------------------------------------------------
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