-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
EZP-31595: Added embedded permission check in UrlAliasRouter #57
Conversation
eZ/Bundle/EzPublishCoreBundle/Resources/views/default/content/embed.html.twig
Outdated
Show resolved
Hide resolved
{% set parameters = { | ||
"isEmbed": true | ||
} %} | ||
{% if location is defined %} | ||
<h3><a href="{{ ez_path(location) }}">{{ content_name }}</a></h3> | ||
<h3><a href="{{ ez_path(location, parameters) }}">{{ content_name }}</a></h3> | ||
{% else %} | ||
<h3><a href="{{ ez_path(content) }}">{{ content_name }}</a></h3> | ||
<h3><a href="{{ ez_path(content, parameters) }}">{{ content_name }}</a></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this rather skip generating link if user does not have access?
As in:
- The link will always go to full view, which implies user needs to have full access
- So rather then doing the checks here in the router, the approach is maybe rather to check rights when rendering embed and pass variable to template to let it skip link if user does not have access to full view (if template is rendered it's already implied user has access to see it, at least embed view of it)
same goes below for inline embed view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this rather skip generating link if user does not have access?
@andrerom I'm not really sure right now. The links are present also in other places in the app even when the user does not have access to linked content, so that's why I decided to kinda go with this solution. Should I change it for the solution you mentioned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, otherwise we are just pushing the issue elsewhere as the user will click on a link and get exception. But maybe @alongosz has some perspective on this as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm against this idea and @andrerom seems to agree on that. I don't feel like Router should check any permissions. Generating a route is different from viewing a content item. You should be able to generate any route but it should be decided elsewhere wether the user has an access to view it and he should be shown a link.
RequestContext $requestContext, | ||
LoggerInterface $logger = null | ||
) { | ||
$this->locationService = $locationService; | ||
$this->urlAliasService = $urlAliasService; | ||
$this->contentService = $contentService; | ||
$this->generator = $generator; | ||
$this->repository = $repository; | ||
$this->permissionResolver = $this->repository->getPermissionResolver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never do this. Pass PermissionResolver
as another dependency and let container builder to inject it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, considering PermissionResolver is already decoupled and available as a service.
* @return string The generated URL | ||
* | ||
* @throws NotFoundException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FQCN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion Router should be permission agnostic and let the business logic / presentation layer decide what to do with such links (make button disabled, display message and so on).
Closing this PR as Router should be left intact in this case. |
Checklist:
$ composer fix-cs
).