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

feat: add EntityEdgeDeletionAuthorizationInferenceBehavior for canViewerDeleteAsync #243

Conversation

wschurman
Copy link
Member

@wschurman wschurman commented Jun 24, 2024

Why

This PR adds a new concept for optimized evaluation of canViewerDeleteAsync: EntityEdgeDeletionAuthorizationInferenceBehavior.

The way it works is: when the method goes to recursively authorize all cascading deletes/set-nulls for an entity being checked in canViewerDeleteAsync, an application developer can specify that checking one instance of an edge of an association type is sufficient for inferring that all edges share the same privacy checks and loading all of them isn't necessary. Without this, all edges are loaded and authorization to cascade delete / set null are checked individually.

This is more of a best-effort optimistic evaluation to tell ahead of time whether a deletion will succeed or fail, and is not used during actual deletion since an application developer may apply it incorrectly.

It was inspired by this comment: #224 (review)

How

Add concept with explanation in comments, add tests.

Test Plan

Run tests.

@wschurman wschurman force-pushed the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch from bc50215 to 3df1bab Compare June 24, 2024 21:13
Copy link
Member Author

wschurman commented Jun 24, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @wschurman and the rest of your teammates on Graphite Graphite

@wschurman wschurman force-pushed the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch from 3df1bab to 90fd858 Compare June 24, 2024 21:45
@wschurman wschurman changed the base branch from main to 06-24-feat_add_convenience_method_for_loading_first_of_many_by_simple_field_equality June 24, 2024 21:45
@wschurman wschurman force-pushed the 06-24-feat_add_convenience_method_for_loading_first_of_many_by_simple_field_equality branch from 43e7c9c to 2b13138 Compare June 25, 2024 18:13
@wschurman wschurman force-pushed the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch from 90fd858 to 79be321 Compare June 25, 2024 18:13
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (15117fc) to head (7954f53).

Current head 7954f53 differs from pull request most recent head 265b641

Please upload reports for the commit 265b641 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #243   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           72        72           
  Lines         1949      1970   +21     
  Branches       267       278   +11     
=========================================
+ Hits          1949      1970   +21     
Flag Coverage Δ
integration 100.00% <100.00%> (ø)
unittest 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wschurman wschurman force-pushed the 06-24-feat_add_convenience_method_for_loading_first_of_many_by_simple_field_equality branch from 2b13138 to 0492011 Compare June 25, 2024 18:45
@wschurman wschurman force-pushed the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch 3 times, most recently from 31cef74 to 7954f53 Compare June 25, 2024 21:37
@wschurman wschurman changed the title feat: add EntityEdgeDeletionPermissionInferenceBehavior for canViewerDeleteAsync feat: add EntityEdgeDeletionAuthorizationInferenceBehavior for canViewerDeleteAsync Jun 25, 2024
@wschurman wschurman force-pushed the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch from 7954f53 to 265b641 Compare June 25, 2024 22:14
@wschurman wschurman changed the base branch from 06-24-feat_add_convenience_method_for_loading_first_of_many_by_simple_field_equality to main June 25, 2024 22:14
@wschurman wschurman marked this pull request as ready for review June 25, 2024 22:18
@wschurman wschurman requested review from ide and quinlanj June 25, 2024 22:18
Copy link
Member Author

One concept I'd like to be able to express alongside this (that I haven't figured out yet) is the ability to ensure canViewerDeleteAsync doesn't load too many entities unexpectedly due to a forgotten edgeDeletionAuthorizationInferenceBehavior specification somewhere in the cascade tree.

Put another way, the most common use of this will likely be doing a simple optimistic check ahead of long-running bulk/batch deletion of a tree of entities. It'd be nice to be able to limit how many entities can be loaded in that execution of canViewerDeleteAsync to prevent OOM.

@wschurman wschurman merged commit 162b192 into main Jun 27, 2024
1 check passed
@wschurman wschurman deleted the 06-24-feat_add_entityedgedeletionpermissioninferencebehavior_for_canviewerdeleteasync branch June 27, 2024 19:33
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.

2 participants