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: rbac client side code #26694

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

feat: rbac client side code #26694

wants to merge 24 commits into from

Conversation

zlwaterfield
Copy link
Contributor

@zlwaterfield zlwaterfield commented Dec 5, 2024

Changes

See issue: #24512

This PR is adding the main UI for RBAC behind a feature flag. This is all client side and only available for those with the feature flag. This is just the first PR, more to come. This should not affect any existing users.

Added

  • organization roles settings
  • project access control settings
  • resource access control in side panel - for insight, dashboards, feature flags and notebooks
  • links to access control from existing dashboard sharing and feature flags

See slack #project-rbac for next steps.

Role management:
Screenshot 2024-12-10 at 11 44 42 AM

Project access:
Screenshot 2024-12-10 at 11 44 38 AM

Resource access control:
Screenshot 2024-12-10 at 11 44 32 AM

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

It doesn't have an impact.

How did you test this code?

Manually tested

  • without feature flag (free, paid, teams and enterprise)
  • with feature flag (free, paid, teams and enterprise)
  • tested pay gates as well

@zlwaterfield zlwaterfield self-assigned this Dec 5, 2024
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Size Change: +64 B (+0.01%)

Total Size: 1.11 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.11 MB +64 B (+0.01%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

8 snapshot changes in total. 0 added, 8 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@zlwaterfield zlwaterfield marked this pull request as ready for review December 10, 2024 16:47
@zlwaterfield zlwaterfield requested review from benjackwhite, Twixes and raquelmsmith and removed request for benjackwhite and Twixes December 10, 2024 16:47
@zlwaterfield zlwaterfield changed the title WIP feat: rbac client side code feat: rbac client side code Dec 10, 2024
@zlwaterfield zlwaterfield requested a review from Twixes December 10, 2024 16:59
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

14 snapshot changes in total. 0 added, 14 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

I love this PR so much. No idea if this is because I'm seeing a lot of my own code and having an incredibly vain moment or if it's because your modifications / rewrite is so fantastic. I'm gonna call this a fine cocktail of the both of us called the Ben-Zachary 😍

All of my comments outside the activity scope stuff can be follow up rather than blocking 🙌

<div className="my-1">
<SimplLevelComponent
size="small"
level={access_level}
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing missing here potentially is a notice to indicate if the default access level is higher than the selected level (making it clear that the default level of "editor" overrides "viewer" for example

@@ -518,6 +528,11 @@ export const notebookLogic = kea<notebookLogicType>([
)
},
setLocalContent: async ({ updateEditor, jsonContent }, breakpoint) => {
if (values.notebook?.user_access_level !== 'editor') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Edge case - If user A has the notebook open and then user B swaps the permissions to view only user A can get stuck in a state where the local content is there but the API requests failed... We probs need an alert if the API response indicates no permissions and then some sort of refresh.

Copy link
Contributor Author

@zlwaterfield zlwaterfield Dec 11, 2024

Choose a reason for hiding this comment

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

Yeah good point, we probably need a permission probe across all resources tbh.

frontend/src/lib/components/RestrictedArea.tsx Outdated Show resolved Hide resolved
<div>
<h3>Access control</h3>
<LemonBanner type="info" className="mb-4">
Permissions have moved! We're rolling out our new access control system. Click below to open it.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice system

Copy link
Contributor

Choose a reason for hiding this comment

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

Although we may need to consider still showing the old UI if there are some configurations set. Depends on whether we will go for an all-in-one migration or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only renders when the flag is on so my idea was we migrate users and then turn on the flag but that might be too simplistic so I'll keep that in mind.

frontend/src/scenes/persons/personsLogic.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/pipeline/pipelineLogic.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/pipeline/pipelineNodeLogic.tsx Outdated Show resolved Hide resolved
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.

3 participants