Skip to content

Commit

Permalink
allow removing pw from public links (#3094)
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj authored Jul 21, 2022
1 parent 51b01e5 commit bb0a604
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-publiclink-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Allow removing password from public links

When using cs3 public link share manager passwords would never be removed. We now remove the
password when getting an update request with empty password field

https://github.com/cs3org/reva/pull/3094
15 changes: 10 additions & 5 deletions pkg/publicshare/manager/cs3/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,17 @@ func (m *Manager) UpdatePublicShare(ctx context.Context, u *user.User, req *link
case link.UpdatePublicShareRequest_Update_TYPE_EXPIRATION:
ps.PublicShare.Expiration = req.Update.Grant.Expiration
case link.UpdatePublicShareRequest_Update_TYPE_PASSWORD:
h, err := bcrypt.GenerateFromPassword([]byte(req.Update.Grant.Password), m.passwordHashCost)
if err != nil {
return nil, errors.Wrap(err, "could not hash share password")
if req.Update.Grant.Password == "" {
ps.Password = ""
ps.PublicShare.PasswordProtected = false
} else {
h, err := bcrypt.GenerateFromPassword([]byte(req.Update.Grant.Password), m.passwordHashCost)
if err != nil {
return nil, errors.Wrap(err, "could not hash share password")
}
ps.Password = string(h)
ps.PublicShare.PasswordProtected = true
}
ps.Password = string(h)
ps.PublicShare.PasswordProtected = true
default:
return nil, errtypes.BadRequest("no valid update type given")
}
Expand Down

0 comments on commit bb0a604

Please sign in to comment.