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

Return 403 when user is not permitted to lock #4292

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions changelog/unreleased/return-403-when-not-lock-permitted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Return 403 when user is not permitted to log

When a user tries to lock a file, but doesn't have write access, the correct status code is `403` not `500` like we did until now

https://github.com/cs3org/reva/pull/4292
9 changes: 7 additions & 2 deletions internal/http/services/owncloud/ocdav/locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,15 @@ func (s *svc) lockReference(ctx context.Context, w http.ResponseWriter, r *http.
// this actually is a name based lock ... ugh
token, err = s.LockSystem.Create(ctx, now, ld)
if err != nil {
if _, ok := err.(errtypes.Aborted); ok {
switch err.(type) {
case errtypes.Aborted:
return http.StatusLocked, err
case errtypes.PermissionDenied:
return http.StatusForbidden, err
default:
return http.StatusInternalServerError, err

}
return http.StatusInternalServerError, err
}

defer func() {
Expand Down
Loading