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

Merge access policies #1041

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
16 changes: 15 additions & 1 deletion app/pages/project/access/ProjectAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,22 @@ export const ProjectAccessPage = () => {
const [editingUserRow, setEditingUserRow] = useState<UserRow | null>(null)
const projectParams = useParams('orgName', 'projectName')
const { data: policy } = useApiQuery('projectPolicyView', projectParams)
const { data: orgPolicy } = useApiQuery('organizationPolicyView', {
orgName: projectParams.orgName,
})
Comment on lines +52 to +54
Copy link
Contributor

Choose a reason for hiding this comment

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

If a user doesn't have permissions for this, what would happen?

Copy link
Collaborator Author

@david-crespo david-crespo Jul 11, 2022

Choose a reason for hiding this comment

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

Great question! That could happen if they lacked the read permission on the org (you can read the policy if you can read the resource), and they would not be able to see any permissions that are inherited from the org. The best we could do is not error and maybe say "there may be other people who are are getting access through the org, but you can't see the org so we can't tell you".

This is another argument against doing this client-side, possibly also an argument for tweaking the permissions model.


// user can also get roles from the silo (and possibly the fleet?) but the
// silo policy view endpoint is `/silos/:siloName/policy`, and we don't have
// the silo name, so we can't fetch it yet. need to think about this

const combinedPolicy = {
roleAssignments: [
...(policy?.roleAssignments || []),
...(orgPolicy?.roleAssignments || []),
],
}

const rows = useUserAccessRows(policy, projectRoleOrder)
const rows = useUserAccessRows(combinedPolicy, projectRoleOrder)

const queryClient = useApiQueryClient()
const updatePolicy = useApiMutation('projectPolicyUpdate', {
Expand Down