feat(search): Add canViewEntityPage permission flag field to search results
Adds canViewEntityPage to the EntityPrivileges GraphQL type, allowing clients to check entity page view permissions through the standard privileges field instead of relying on search result extraProperties.
What Changed
This PR exposes the existing VIEW_ENTITY_PAGE privilege through the GraphQL EntityPrivileges type, making it available via the entity query's privileges field.
Changes Made:
- Added
canViewEntityPage: Boolean field to GraphQLEntityPrivilegestype - Created
AuthorizationUtils.isViewEntityPageAuthorized()authorization check method - Made
PoliciesConfig.VIEW_ENTITY_PAGE_PRIVILEGEpublic (was package-private) - Updated
EntityPrivilegesResolver.addCommonPrivileges()to populate the new field
Now: Can now check view permissions directly through the entity's privileges field:
entity {
... on Dataset {
urn
type
privileges {
canViewEntityPage # Boolean
}
}
}
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: All tests successful. No failed tests found.
:loudspeaker: Thoughts on this report? Let us know!
@yorubaphenom Thanks for the PR, can you add screenshots also depicting before and after state
Please add unit tests
We already expose privileges via the EntityPrivilegeResolver. So, it's only a matter of adding the value of
AuthUtils.canViewEntityas canViewEntityPage inEntityPrivilegesand that should be it. You can then use it like this:entity { ... on Dataset { privileges { canViewEntityPage } } }That said,
VIEW_AUTHORIZATION_ENABLEDflag can be used to restrict search results based on available permissions. So this new privilege may not even be necessary unless there is any other use case.
thanks @sakethvarma397 I have implemented your suggestions. The use case for us is on the search page we don't want to show the entity sidebar to users who don't have the viewEntity permissions.