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

Refactor to avoid conflicts between Permission.excludes and Permission.needs #77

Merged
merged 2 commits into from
May 22, 2024

Conversation

danwuSBU
Copy link

@danwuSBU danwuSBU commented May 22, 2024

We can get into a weird state with conflicting logic by doing the following:

d = Denial(('a', 'c'))
p = Permission(('a', 'c'))

u = d.union(p)
#  now u has ('a', 'c') in BOTH needs and excludes

With this refactoring, a need can be needed or excluded, but not both. This change is not expected to break anything and just handle the edge case described above.

@danwuSBU danwuSBU force-pushed the get_rid_of_excludes branch from f707678 to 2226ece Compare May 22, 2024 19:35
Copy link
Member

@Abdur-rahmaanJ Abdur-rahmaanJ left a comment

Choose a reason for hiding this comment

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

The PR is great. Thanks for spotting the issue and thanks @kevin-brown for the input.
Just PR docs should be in the format [ statement ] -> code explanations.

Flask-principal was keeping records for both needs and excludes. This PR simplifies the logic by keeping only needs, reducing excludes to not needs.

@danwuSBU danwuSBU force-pushed the get_rid_of_excludes branch from effc7f9 to f2dfeb2 Compare May 22, 2024 19:52
@Abdur-rahmaanJ
Copy link
Member

closes #78

@Abdur-rahmaanJ Abdur-rahmaanJ merged commit a20b549 into pallets-eco:main May 22, 2024
6 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants