-
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
Open
zlwaterfield
wants to merge
9
commits into
master
Choose a base branch
from
zach/rbac/6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+620
−310
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ecfa00e
Add access denied middleware
zlwaterfield f98f20e
Update some more user access control types
zlwaterfield 2e9ca06
add api middleware for 403s
zlwaterfield bfbfa22
Create AccessControlAction.tsx
zlwaterfield e0be46d
hookup access control action wrapper
zlwaterfield 3bad996
Add insight read permissions
zlwaterfield d7eff08
add user access control to more serializers
zlwaterfield 70cea73
more access control wrappers
zlwaterfield f7f7070
More access limitations
zlwaterfield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useValues } from 'kea' | ||
|
||
import { accessControlLogic } from '~/layout/navigation-3000/sidepanel/panels/access_control/accessControlLogic' | ||
|
||
import { WithAccessControl } from '../../types' | ||
|
||
interface AccessControlActionProps { | ||
children: (props: { disabled: boolean; disabledReason: string | null }) => React.ReactElement | ||
userAccessLevel?: WithAccessControl['user_access_level'] | ||
requiredLevels: WithAccessControl['user_access_level'][] | ||
resourceType?: string | ||
} | ||
|
||
export const AccessControlAction = ({ | ||
children, | ||
userAccessLevel, | ||
requiredLevels, | ||
resourceType = 'resource', | ||
}: AccessControlActionProps): JSX.Element => { | ||
const { hasResourceAccess } = useValues(accessControlLogic) | ||
|
||
const hasAccess = hasResourceAccess({ userAccessLevel, requiredLevels }) | ||
const disabledReason = !hasAccess | ||
? `You don't have sufficient permissions for this ${resourceType}. Your access level (${userAccessLevel}) doesn't meet the required level (${requiredLevels.join( | ||
' or ' | ||
)}).` | ||
: null | ||
|
||
return children({ | ||
disabled: !hasAccess, | ||
disabledReason, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function AccessDenied(): JSX.Element { | ||
return ( | ||
<div className="flex flex-col items-center max-w-2xl p-4 my-24 mx-auto text-center"> | ||
<h1 className="text-3xl font-bold mt-4 mb-0">Access denied</h1> | ||
<p className="text-sm mt-3 mb-0"> | ||
You don't have access to this resource. Please contact support if you think this is a mistake. | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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