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

Make permission checks namespace safe #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yippie
Copy link

@yippie yippie commented Jul 10, 2024

Fixes #153

Fixes an issue where including trigger action framework in a namespaced package makes custom permission checks fail if the permission is not in the same namespace.

This requires using 2 SOQL queries to connect the User to the Custom Permission. To minimize the number of queries and processing done, the following strategies were employed:

  • Blindly get ALL custom permissions assigned to the user instead of parsing through the actions and pulling out permissions to check one at a time. Then, when checking permissions, simply check if the permissions list contains the desired permission. The allows the queries for user permissions to happen exactly once.
  • Move permission checks to a dedicated, static class, that can cache and share the permission with all handlers, including finalizers, that happen in a transaction context.

Unit tests were updated to mock permissions the new way but were otherwise untouched as the goal of this change is to cause zero change in behavior or functionality.

  • Tests pass
  • [N/A no behavior change] Appropriate changes to README are included in PR

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.

Custom Permissions check not namespace safe
1 participant