-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Beautify admin routes #56
Comments
My personal opinion is that URL format doesn't matter for a backend. My guess is that the end users of a backend don't care about URLs because they don't even look at them. They just want the backend to work as expected. However, even if we eventually add this feature, I think it's too early to do it now. I propose to "play" a bit more with this bundle until we decide what we want to do with URLs. |
Was thinking about something though. If you have a "bigger" backoffice with many people using it, it could be good to use the native Security component to restrict access for some entities and some actions. For example if you want back-end users only to "view" things but never "edit" them, you can have this configuration in your security.yml: security:
role_hierarchy:
ROLE_MANAGER: ROLE_USER
ROLE_MODERATOR: ROLE_MANAGER
ROLE_ADMIN: ROLE_MODERATOR
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
access_control:
- { path: ^/admin, roles: ROLE_MANAGER }
- { path: ^/admin/([^/]+)/edit, roles: ROLE_MODERATOR }
- { path: ^/admin/([^/]+)/delete, roles: ROLE_ADMIN }
|
For now I'm closing this issue as won't fix for the reasons explained in #93. @Pierstoval you provided a good use case for this feature ... but I think that in a real backend, this could be better solved using a custom security voter. Moreover, since Symfony 2.6, it's really easy to create them. |
May I propose that this feature can be still used by user ? I've got another idea : simply move the routing from annotations to files, and use a In the controller, there's a simple way to do this : the "path" parameters are null by default, and with a simple |
@Pierstoval at the end, this is mostly not about "how can we do this" or if there is a simple way to do this. Ultimately, this is about adding some non-trivial feature that in my opinion has a lot of "cons" compared to the few "pros" that it would provide. |
Here are the cons you wrote on #93 :
For the performances : the feature as I may implement it does not create more routes, as there is still one "admin" route, with its optional and "defaulted" parameters. It's mostly related to @manuelj555's PR. With this arguments, I hope that it's gonna make more pros than cons for this feature. I'd be sad if I had to override the native behavior in my apps or use my fork for this and not the original bundle, this just to handle security issues :) I can be convinced at last only if you find a true reason to refuse all these points :D (And crap, I think I deleted my branch, I'll have to redevelop this feature, but no problem if you are convinced ;) ) |
@javiereguiluz : May I propose back another "style" for this feature, as you can see on my branch? https://github.com/Pierstoval/EasyAdminBundle/compare/urls The goal is to only change the routing file to load depending on your "preferred route style". The The usual behavior is unchanged, except for one more redirection to force "list" to be shown in the url, for the This would allow custom setup in What do you think ? |
Well, it has some good points concerning security issues indeed. But I still have concerns about the points raised by Javier and about the future. easy_admin:
entities:
Posts:
roles: ['ROLE_AUTHOR']
class: AppBundle\Entity\Post
Pages:
roles: ['ROLE_AUTHOR']
class: AppBundle\Entity\Page
Categories:
role: [ROLE_WEBMASTER]
class: AppBundle\Entity\Category
list:
roles: ['ROLE_MANAGER']
"Config":
class: AppBundle\Entity\Config
role: ['ROLE_ADMIN'] The DefaultEasyAdminVoter will provide a way to handle every case through code, and handle most common ones through config, without requiring any change in the routing pattern. |
And what if you are using ACLs ? Ok, it's bad :p Your option is good, but then the security comes "out" of the security component. With my PR you can define a security |
It could be handled in the Voter (I had some issues with sf < 2.6 about circular references however... I must check if this is feasible now with the last security improvements and the I'm not in favor of adding security logic inside EasyAdminBundle (and your solution was good considering this), but even if we do not provide a simple way through configuration, we could provide an optional helper in the form of an AbstractVoter for the bundle uses. |
It'd still be heavy, even though it's more convenient for "adaptability" purposes, but as said, I think the goal of EasyAdmin is to keep away from linking with other "out-of-the-box" components. That's why I implemented both "beautifying admin routes" and "custom actions" in the simplest possible way I could (may there are more solutions, but I don't know them yet ;) ) to stay in the rails of EasyAdmin :) |
My urls branch has been rebased on master and updated with docs, if one day it's discussed again |
Now we have this kind of pattern for routes:
{prefix}/?entity={entity}&action={action}
It seems that the pattern always rely on these two elements, which can be "defaulted" if needed, with the method
getNameOfTheFirstConfiguredEntity
and thelist
action by default.What about changing the
@Route
annotation to have a much nicer pattern ?After some tests I've come with 3 different patterns that can certainly match the whole thing:
What do you think ?
The text was updated successfully, but these errors were encountered: