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

ref(dashboards): Modify how permissions are handled for editing/deleting dashboards #80684

Merged

Conversation

harshithadurai
Copy link
Contributor

@harshithadurai harshithadurai commented Nov 13, 2024

Modify how permissions are handled for editing/deleting dashboards:

Previously, users without access to some projects were restricted from editing/deleting dashboards. (Change made here #78615). This PR removes that restriction, and enables restricting edit perms to specific teams.

@harshithadurai harshithadurai requested a review from a team as a code owner November 13, 2024 20:04
@harshithadurai harshithadurai marked this pull request as draft November 13, 2024 20:04
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 13, 2024

This comment was marked as outdated.

Copy link
Member

@narsaynorath narsaynorath left a comment

Choose a reason for hiding this comment

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

Nice. Looks good to me, just gotta clarify if there are any issues with the new behaviour, but technically since it's feature flagged we can merge this

# allow when Open Membership
if obj.organization.flags.allow_joinleave:
return True
if not features.has(
Copy link
Member

Choose a reason for hiding this comment

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

You should just do a if-else with the block on Line 71. It's a bit odd to split it into 2.

Comment on lines 58 to 61
# 2. Dashboard covers all projects or all my projects
# allow when Open Membership
if obj.organization.flags.allow_joinleave:
return True
Copy link
Member

@leedongwei leedongwei Nov 19, 2024

Choose a reason for hiding this comment

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

I believe that this should always be applicable even without the flag. It doesn't need to be nested inside the flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason we don't want to allow this case is because we want to move towards more explicit dashboard permissions via teams. Users should need to assign themselves to a team to get edit perms, regardless of open membership or project assignments. This gives us clearer control over permissions, as team membership is the real factor, not just project coverage. Plus, all data is already queryable, so project-based restrictions are just a proxy for what we really want—team-based permissions. Also, this permissions class is used to only restrict edit and delete access, so anyone can still view any dashboard.

):
# check if user is restricted from editing dashboard
if hasattr(obj, "permissions"):
return obj.permissions.has_edit_permissions(request.user.id)
Copy link
Member

Choose a reason for hiding this comment

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

Adding a once-off function like has_edit_permissions to a permission class seems like a code smell to me.

Have you considered adding dashboard scopes? i.e. dashboard:write, dashboard:read, dashboard:admin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We did consider this, but decided that the scopes are being used for more generic purposes right now (like team and project based access). However, we’ll definitely look into this approach if it becomes more relevant down the line.

@harshithadurai harshithadurai merged commit 215e7f7 into master Nov 25, 2024
49 checks passed
@harshithadurai harshithadurai deleted the harshi/ref/modify-permission-restrictions-for-dashboards branch November 25, 2024 20:32
harshithadurai added a commit that referenced this pull request Nov 26, 2024
…edit dashboards (#81181)

add frontend check to allow managers and owners to always be able to
edit dashboards, and dashboard edit perms. this won't work until
#80684 is merged

---------

Co-authored-by: harshithadurai <[email protected]>
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
…ing dashboards (#80684)

Modify how permissions are handled for editing/deleting dashboards:

Previously, users without access to some projects were restricted from
editing/deleting dashboards. (Change made here #78615). This PR removes
that restriction, and enables restricting edit perms to specific teams.

---------

Co-authored-by: harshithadurai <[email protected]>
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
…edit dashboards (#81181)

add frontend check to allow managers and owners to always be able to
edit dashboards, and dashboard edit perms. this won't work until
#80684 is merged

---------

Co-authored-by: harshithadurai <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants