-
Notifications
You must be signed in to change notification settings - Fork 308
Implement fallback to anonymous role permissions #3141
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,9 +128,21 @@ public bool AreRoleAndOperationDefinedForEntity(string entityIdentifier, string | |
| return true; | ||
| } | ||
| } | ||
|
|
||
| // If the role is not found or doesn't define the operation, | ||
| // fall back to the anonymous role's permissions | ||
| // since anonymous access implies the entity is publicly accessible. | ||
| if (valueOfEntityToRole.RoleToOperationMap.TryGetValue(ROLE_ANONYMOUS, out RoleMetadata? anonymousRoleMetadata)) | ||
| { | ||
| if (anonymousRoleMetadata!.OperationToColumnMap.ContainsKey(operation)) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
|
Comment on lines
+132
to
+141
|
||
| } | ||
| } | ||
|
|
||
| return false; | ||
| return false; | ||
|
Comment on lines
+143
to
+145
|
||
| } | ||
|
|
||
| public bool IsStoredProcedureExecutionPermitted(string entityName, string roleName, SupportedHttpVerb httpVerb) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback to anonymous role permissions in AreRoleAndOperationDefinedForEntity should be accompanied by a similar fallback in AreColumnsAllowedForOperation. When a filter references fields on an anonymous-accessible entity, the field-level authorization check (called after entity-level check in GraphQLFilterParsers.cs line 158) should also fall back to anonymous role's column permissions. Without this, authenticated users may still get "Access forbidden to a field referenced in the filter" errors even after this entity-level fix.