Skip to content

feat: add organization-scoped permission checks to deployment settings #14063

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

Merged
merged 20 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix edit org member check
Looks like the resource needs to be organization_member, not user.

Also we were not passing through the edit permission to the edit and
delete buttons.
  • Loading branch information
code-asher committed Aug 1, 2024
commit 2a8c38b6d188268465e355057ec2005973a6776a
8 changes: 4 additions & 4 deletions site/src/api/queries/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ export const organizationPermissions = (organizationId: string | undefined) => {
queryFn: () =>
API.checkAuthorization({
checks: {
viewUsers: {
viewMembers: {
object: {
resource_type: "user",
resource_type: "organization_member",
organization_id: organizationId,
},
action: "read",
},
editUsers: {
editMembers: {
object: {
resource_type: "user",
resource_type: "organization_member",
organization_id: organizationId,
},
action: "update",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const OrganizationMembersPage: FC = () => {
<Stack>
{Boolean(error) && <ErrorAlert error={error} />}

{permissions.editUsers && (
{permissions.editMembers && (
<AddOrganizationMember
isLoading={addMemberMutation.isLoading}
onSubmit={async (user) => {
Expand Down Expand Up @@ -129,7 +129,7 @@ const OrganizationMembersPage: FC = () => {
allAvailableRoles={organizationRolesQuery.data}
oidcRoleSyncEnabled={false}
isLoading={updateMemberRolesMutation.isLoading}
canEditUsers
canEditUsers={permissions.editMembers}
onEditRoles={async (newRoleNames) => {
try {
await updateMemberRolesMutation.mutateAsync({
Expand All @@ -145,7 +145,7 @@ const OrganizationMembersPage: FC = () => {
}}
/>
<TableCell>
{member.user_id !== me.id && (
{member.user_id !== me.id && permissions.editMembers && (
<MoreMenu>
<MoreMenuTrigger>
<ThreeDotsButton />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const OrganizationSettingsPage: FC = () => {
// shows on this page but disable the fields, although that could be
// confusing?
if (!permissions.editOrganization) {
if (permissions.viewAllMembers) {
if (permissions.viewMembers) {
return <Navigate to="members" replace />;
} else if (permissions.viewGrousp) {
return <Navigate to="groups" replace />;
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/ManagementSettingsPage/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const OrganizationSettingsNavigation: FC<
Organization settings
</SidebarNavSubItem>
)}
{permissionsQuery.data.viewUsers && (
{permissionsQuery.data.viewMembers && (
<SidebarNavSubItem
href={urlForSubpage(organization.name, "members")}
>
Expand Down