-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: client side access control (WIP) #27174
base: master
Are you sure you want to change the base?
Conversation
@@ -46,6 +61,13 @@ export const apiStatusLogic = kea<apiStatusLogicType>([ | |||
const data = await response?.json() | |||
if (data.detail === 'This action requires you to be recently authenticated.') { | |||
actions.setTimeSensitiveAuthenticationRequired(true) | |||
} else if (data.code === 'permission_denied') { | |||
// TODO - only do if the RBAC feature flag is enabled |
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.
importing feature flag logic here is breaking this logic so haven't figured out this check yet
if (featureFlags[FEATURE_FLAGS.ROLE_BASED_ACCESS_CONTROL]) { | ||
return true | ||
// TODO: figure out how to access this method | ||
// return hasResourceAccess({ userAccessLevel: dashboard.user_access_level, requiredLevels: ['admin', 'editor'] }) |
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.
Need to figure out how to access access control logic hasResourceAccess
if (featureFlags[FEATURE_FLAGS.ROLE_BASED_ACCESS_CONTROL]) { | ||
return true | ||
// TODO: figure out how to access this method | ||
// return hasResourceAccess({ userAccessLevel: insight.user_access_level, requiredLevels: ['admin', 'editor'] }) |
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.
Need to figure out how to access access control logic hasResourceAccess
Size Change: +547 B (+0.05%) Total Size: 1.11 MB ℹ️ View Unchanged
|
Changes
(this is still a WIP but wanted feedback on the implementation so far)
Follow along with all RBAC changes here: #24512
This PR is starting to layer on the client side access control changes. This PR is trying to layer on these changes without affecting this current experience. The main goal is to block access to actions where the user does not have access (editing, renaming, deleting, etc.). The API handles all this but we want the client to properly render what actions the user has access to.
It includes
AccessControlAction
wrapper component to make the experience consistent for showing the user doesn't have access - takes in required levels and current levels and returns a message if they don't have access and whyhasResourceAccess
method in the access control logic that theAccessControlAction
uses to determine accessTODO:
canEditInsight
andcanEditDashboard
workingcan_edit
and make sure this doesn't break anything + works as expected going forwardNote: this has not been implemented for projects, teams, or environments - it's focused on resources.
Feedback
Asking all leads for reviews as this will affect all teams once implemented. Please provide thoughts/feedback on the way this implemented. This is attempting to make a reuseable pattern to it's easy to add access level checks.
An alternative approach could be to return an object from
hasResourceAccess
which has the disabled reason and the wrapper is not needed.👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Manually testing + will add some snapshots