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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Read/Write Permission #2550

Closed
wants to merge 2 commits into from

Conversation

bear-lover
Copy link

Description

Add Read/Write permission to filebrowser.
It works like ACL in linux

馃毃 Before submitting your PR, please read community, and indicate which issues (in any of the repos) are either fixed or closed by this PR. See GitHub Help: Closing issues using keywords.

  • DO make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • DO make sure you are making a pull request against the master branch (left side). Also you should start your branch off our master.
  • DO make sure that File Browser can be successfully built. See builds and development.
  • DO make sure that related issues are opened in other repositories. I.e., the frontend, caddy plugins or the web page need to be updated accordingly.
  • AVOID breaking the continuous integration build.

Further comments

None.

@bear-lover bear-lover requested a review from o1egl as a code owner July 15, 2023 20:33
Copy link
Member

@o1egl o1egl left a comment

Choose a reason for hiding this comment

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

It fails with the error.

Screenshot 2023-07-17 at 12 10 13

Comment on lines +76 to +78
if !d.CheckReadPerm(r.URL.Path) {
return http.StatusForbidden, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think read permission should be checked here

http/data.go Outdated
Comment on lines 88 to 92
if !rule.Allow {
write = false
} else {
write = strings.Contains(rule.Perm, "write")
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !rule.Allow {
write = false
} else {
write = strings.Contains(rule.Perm, "write")
}
if !rule.Allow {
write = false
continue
}
write = strings.Contains(rule.Perm, "write")

http/data.go Outdated
Comment on lines 98 to 102
if !rule.Allow {
write = false
} else {
write = strings.Contains(rule.Perm, "write")
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !rule.Allow {
write = false
} else {
write = strings.Contains(rule.Perm, "write")
}
if !rule.Allow {
write = false
continue
}
write = strings.Contains(rule.Perm, "write")

Comment on lines +26 to 29
type Perms struct {
Read bool `json:"read"`
Write bool `json:"write"`
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this struct is not used

Comment on lines +54 to +66
const rule = this.rules[index];
const isRead =
ruleName === "read"
? rule.perm.includes("read")
: !rule.perm.includes("read");
const isWrite =
ruleName === "write"
? rule.perm.includes("write")
: !rule.perm.includes("write");
this.rules[index].perm = `${!isRead ? "read" : ""}${
!isRead && !isWrite ? "|" : ""
}${!isWrite ? "write" : ""}`;
},
Copy link
Member

Choose a reason for hiding this comment

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

Why not to store it as an inner object?

perms: {read: true, write: true}

Comment on lines +61 to +63
} else {
read = strings.Contains(rule.Perm, "read")
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's follow the same code style as in CheckWritePerm

Comment on lines +71 to +73
} else {
read = strings.Contains(rule.Perm, "read")
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@o1egl o1egl force-pushed the master branch 2 times, most recently from 813c2e9 to 66dfbb3 Compare July 28, 2023 22:27
@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Aug 28, 2023
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants