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

Doc: access policy fix and expansion #6573

Merged
merged 10 commits into from
Feb 1, 2024
Merged

Conversation

Dhghomon
Copy link
Contributor

@Dhghomon Dhghomon commented Dec 6, 2023

Fixes #6389 where a user noticed that the syntax declaration for access policies makes it look like annotations should be outside the braces when they should be inside, and that we don't have any access policy examples that show where annotations belong either so it took some experimentation to figure it out.

In our current example there is a bit of new learning to do so instead of declaring a new annotation at the same time, it uses the built-in errmessage to show where to add such notes and then mentions in the breakdown below that other annotations can go in this space as well. Plus adds an example where you might see this error: where an app is configured wrongly such that a user is allowed to try to write a post but is prevented by the access policy.

@Dhghomon Dhghomon marked this pull request as ready for review December 6, 2023 06:15
@Dhghomon Dhghomon requested a review from raddevon December 6, 2023 06:15
Copy link
Contributor

@raddevon raddevon left a comment

Choose a reason for hiding this comment

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

Great additions, @Dhghomon! I have some minor suggestions and one concern about an access policy result that I don't follow.

Comment on lines 289 to 290
edgedb error: AccessPolicyError: access policy violation on insert of
default::BlogPost (User must have same ID as blog author)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused how this would be prevented by the access policy. This error message would only trigger if current_user is different from .author.id, but the User for .author is being selected here based on current_user, so they would have to match, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, not a good example as we discussed last week. A better idea struck me which requires two globals but still simple enough and feels much more like a real world example.

@raddevon raddevon changed the title Access policy fix and expansion Doc: access policy fix and expansion Dec 6, 2023
Copy link
Contributor

@raddevon raddevon left a comment

Choose a reason for hiding this comment

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

Looks good. A few minor changes, and this is ready to go!

@Dhghomon
Copy link
Contributor Author

Looks good. A few minor changes, and this is ready to go!

Okay, I think I got them all!

@Dhghomon Dhghomon requested a review from raddevon January 30, 2024 01:59
@Dhghomon
Copy link
Contributor Author

@raddevon Forgot all about this PR! In the meantime a small merge conflict popped up but has now been resolved.

@Dhghomon
Copy link
Contributor Author

Dhghomon commented Feb 1, 2024

Okay, just added f005df8 on which operations return empty sets vs. which will show errors. Adding this is pretty nice as it allows a more thorough explanation on update read vs. update write in the section in which they are introduced.

@raddevon raddevon merged commit 639c91e into master Feb 1, 2024
24 checks passed
@raddevon raddevon deleted the access-policy-fix-and-expansion branch February 1, 2024 12:18
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.

Document Access Policy Annotations
2 participants