Skip to content

Disable stories edit page for users with insufficient permissions #2691

Open
@RichDom2185

Description

@RichDom2185

Reported by a student; reworded and posted here as it is not a major security vulnerability (the API request would still be blocked correctly by the backend, i.e. saving will result in an error if the user has insufficient permissions). Thank you for the report!

Background

The backend already implements the correct access control checks to ensure this editing stories is not possible unless the user has sufficient permissions:

And the frontend also already hides the edit button in the stories table:

storyActions={story => {
const isAuthor = storiesUserId === story.authorId;
const hasWritePermissions =
storiesRole === StoriesRole.Moderator || storiesRole === StoriesRole.Admin;
return (
<StoryActions
storyId={story.id}
handleDeleteStory={handleDeleteStory}
handleTogglePin={handleTogglePinStory}
handleMovePinUp={handleMovePinUp}
handleMovePinDown={handleMovePinDown}
canView // everyone has view permissions, even anonymous users
canEdit={isAuthor || hasWritePermissions}

But manually editing the URL from /view/<story_id> to /edit/<story_id> still results in the edit component showing.

Proposal

Redirect /edit/<story_id>/view/<story_id> when the user has insufficient permissions to edit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingminorLess important than important, but more than nice-to-have

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions