Skip to content

Commit

Permalink
Merge pull request #4292 from kobergj/403OnLock
Browse files Browse the repository at this point in the history
Return 403 when user is not permitted to lock
  • Loading branch information
kobergj authored Oct 27, 2023
2 parents 2921b01 + 40f1a0b commit fdeb764
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit fdeb764

Please sign in to comment.