Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resources for groups #4

Open
fruitloop opened this issue Jan 22, 2018 · 4 comments
Open

resources for groups #4

fruitloop opened this issue Jan 22, 2018 · 4 comments

Comments

@fruitloop
Copy link

Hi,

I'm using Slim v3 and I want to secure a single group with ACL.
I have a "problem".

When I secure a group like this:

$app->group('/extremelyLongStringThatIsNotFunToType', function() {
  $this->get('/short', function($req, $res, $args) {...});
  $this->get('/and', function($req, $res, $args) {...});
  $this->get('/readable', function($req, $res, $args) {...});
})->add(new \Geggleto\Acl\AclRepository([$_SESSION["role"]], [
  "resources" => ["/extremelyLongStringThatIsNotFunToType/short", "/extremelyLongStringThatIsNotFunToType/and", "/extremelyLongStringThatIsNotFunToType/readable"],
  "roles" => ["admin", "user"],
  "assignments" => [
    "allow" => [
      "admin" => ["/extremelyLongStringThatIsNotFunToType/short", "/extremelyLongStringThatIsNotFunToType/and", "/extremelyLongStringThatIsNotFunToType/easy"],
      "user" => ["/extremelyLongStringThatIsNotFunToType/short"]
    "deny" => []
  ]
]));

the resources get rather long, is there a way to use a shorter form (like only the path inside the group and not the whole group/path string?)

@geggleto
Copy link
Owner

Hey, I will have to look into some solutions.

For now I would recommend putting the resource string into the container to save some typing. In theory I think I might be able to merge all of the "allow" assignments to construct resources and roles ?

@fruitloop
Copy link
Author

Hi,

you mean something like this?

$long = 'extremelyLongStringThatIsNotFunToType';
"resources" => ["$long/short", "$long/and", "$long/readable"]

Yesterday I was wondering if we could use the names $app->get(...)->setName('foo'); to define the routes. That would work for me since I am naming about every route to use in my TWIG templates.

@geggleto
Copy link
Owner

Hmm that's an interesting thought. If we wanted to use the app hooks we would need to wrap the Slim App to intercept those method calls.

@lotharthesavior
Copy link
Contributor

AOP coming to the scene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants