Skip to content

Conversation

@deluxetom
Copy link

No description provided.


try {
return $this->rbacManager->hasPermission($attribute, $user->getId());
return $this->rbacManager->hasPermission($attribute, $user->getUserIdentifier());
Copy link

@anthony-321 anthony-321 Oct 14, 2024

Choose a reason for hiding this comment

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

I think this could break things because subsequent queries rely on the user id, not the public-facing user identifier (email, username, etc). It uses the id for subsequent authorization queries.

But as you know, there is no UserInterface::id:
https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Security/Core/User/UserInterface.php

For me, static analysis has highlighted that this bundle is designed to the wrong interface (UserInterface instead of User). I think that the fix here would be to depend on User.

Choose a reason for hiding this comment

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

We could also keep it the way it is, but change the SQL queries

Copy link
Author

Choose a reason for hiding this comment

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

yea I think the issue is that the User entity comes from the config and we're not sure that id will exist either.

in our case, I think userIdentifier works better?

Choose a reason for hiding this comment

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

userIdentifier works, I think we'd just need to update Rbac::hasPermission() to transform the userIdentifier string into an int for subsequent queries. We could also modify PermissionRepository::hasPermission(). Downside is more lookups/joins as opposed to original implementation that relies only on ids.

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

Successfully merging this pull request may close these issues.

3 participants