My Mojolicious application has its own authentication mechanism, which I implement in the routing state with the name auth_permission
:
$app->add_condition(auth_permission => sub { return is_user_allowed(...) ? 1 : 0; });
So my routes look something like this:
my $r = $app->routes; $r->get('/prefs')
The to()
rules are handled correctly: GET /objects
gives me a list of objects, and GET /objects/delete/42
deletes object 42.
The problem is that the permission of view objects
checked for both queries, although the second route should check the permission of delete objects
.
The reason is that /objects/delete/42
is the path below /objects
. The same problem does not occur with the /prefs
route, which does not have a common base with other routes.
My current workaround is to put the rule for /objects
below one for /objects/delete/:id
, but that a) is unbalanced and b) is about to break when another developer is editing the file. Is it possible to explicitly disable nesting behavior in this case?
source share