Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

barw4
Copy link
Member

@barw4 barw4 commented Apr 28, 2020

Question Answer
JIRA issue EZP-31595
Type bug
Target eZ Platform version v3.0
BC breaks no
Tests pass yes
Doc needed no

Checklist:

  • PR description is updated.
  • Tests are implemented.
  • Added code follows Coding Standards (use $ composer fix-cs).
  • PR is ready for a review.

@barw4 barw4 added Bug Something isn't working Work in progress labels Apr 28, 2020
@barw4 barw4 self-assigned this Apr 28, 2020
@barw4 barw4 changed the base branch from master to 1.0 April 28, 2020 20:01
@barw4 barw4 changed the title [WIP] EZP-31595: Added embedded permission check in UrlAliasRouter EZP-31595: Added embedded permission check in UrlAliasRouter May 12, 2020
Comment on lines +3 to +9
{% 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>
Copy link
Contributor

@andrerom andrerom May 12, 2020

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.

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Contributor

@webhdx webhdx left a 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();
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FQCN

Copy link
Contributor

@Nattfarinn Nattfarinn left a 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).

@barw4
Copy link
Member Author

barw4 commented May 26, 2020

Closing this PR as Router should be left intact in this case.

@barw4 barw4 closed this May 26, 2020
@barw4 barw4 deleted the EZP-31595 branch May 26, 2020 08:16
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Something isn't working Ready for review
Development

Successfully merging this pull request may close these issues.

4 participants