Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: restrict edit schedule access #2698

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 6 commits into from
Jul 1, 2022

Conversation

AbhineetJain
Copy link
Contributor

@AbhineetJain AbhineetJain commented Jun 28, 2022

This PR restricts the link to editing workspace schedule and the actual page access to users with update access to the workspace.

Subtasks

  • hide the Edit schedule link for users without update access.
  • hide the plus-minus buttons for users without update access.
  • add relevant story
  • fetch permissions on workspace schedule page
  • display error in case access is forbidden

Fixes #2655

Screenshots

Screen Shot 2022-07-01 at 3 34 43 PM

Screen Shot 2022-07-01 at 4 45 40 AM

@AbhineetJain AbhineetJain requested a review from a team as a code owner June 28, 2022 07:12
@AbhineetJain
Copy link
Contributor Author

I need some help to reproduce this flow where a user has read access to another workspace but no update access, so I can properly test it.

@AbhineetJain AbhineetJain force-pushed the abhineetjain/2655-hide-edit-schedule-link branch from 0acd837 to 73cbad7 Compare June 28, 2022 23:07
}

// Theoretically impossible - log and bail
Copy link
Member

Choose a reason for hiding this comment

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

Potentially unpopular opinion up for debate: I think I'd rather the user run into an error state here so I know we've reached the 'theoretically impossible' state and we have a bug on their hands.

Copy link
Contributor Author

@AbhineetJain AbhineetJain Jul 1, 2022

Choose a reason for hiding this comment

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

I think we should still provide our users a way to get out of the error state. For example, in this case we are just redirecting to /. Maybe we can show them a generic error like "This should not have happened. Go to workspaces."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Additionally, we can also show them the Report an issue link opening in new tab.

@Kira-Pilot
Copy link
Member

Kira-Pilot commented Jun 29, 2022

This looks good to me! I also am not sure how to test. Snapshots look good, though, so I'll approve.

@AbhineetJain AbhineetJain force-pushed the abhineetjain/2655-hide-edit-schedule-link branch from 73cbad7 to 8870ae3 Compare July 1, 2022 08:48
@AbhineetJain
Copy link
Contributor Author

AbhineetJain commented Jul 1, 2022

I was able to test this flow by editing the permissions for organization-member role to include:

// rbac/builtin.go#L145
{
    ResourceType: ResourceWorkspace.Type,
    ResourceID:   "*",
    Action:       ActionRead,
},

@AbhineetJain AbhineetJain requested a review from Kira-Pilot July 1, 2022 14:20
@AbhineetJain AbhineetJain force-pushed the abhineetjain/2655-hide-edit-schedule-link branch from bd64519 to 2233bdc Compare July 1, 2022 19:35
@AbhineetJain AbhineetJain force-pushed the abhineetjain/2655-hide-edit-schedule-link branch from f566375 to 2d2522d Compare July 1, 2022 19:57
@AbhineetJain AbhineetJain enabled auto-merge (squash) July 1, 2022 20:31
@AbhineetJain AbhineetJain merged commit c1b3080 into main Jul 1, 2022
@AbhineetJain AbhineetJain deleted the abhineetjain/2655-hide-edit-schedule-link branch July 1, 2022 20:43
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.

Bug: edit schedule link and form render for others' workspaces
2 participants