Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Fix expired authenticated public link error code (cs3org#3528)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 authored Dec 8, 2022
1 parent 8078ac6 commit dd3333f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-authenticated-expired-publiclinks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fix expired authenticated public link error code

On an expired authenticated public link, the error returned
was 401 unauthorized, behaving differently from
a not-authenticated one, that returns 404 not found.
This has been fixed, returning 404 not found.

https://github.com/cs3org/reva/pull/3528
13 changes: 6 additions & 7 deletions pkg/cbox/publicshare/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth
return nil, err
}
cs3Share := conversions.ConvertToCS3PublicShare(s)
if expired(cs3Share) {
if err := m.cleanupExpiredShares(); err != nil {
return nil, err
}
return nil, errtypes.NotFound(token)
}
if s.ShareWith != "" {
if !authenticate(cs3Share, s.ShareWith, auth) {
// if check := checkPasswordHash(auth.Password, s.ShareWith); !check {
Expand All @@ -462,13 +468,6 @@ func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth
}
}

if expired(cs3Share) {
if err := m.cleanupExpiredShares(); err != nil {
return nil, err
}
return nil, errtypes.NotFound(token)
}

return cs3Share, nil
}

Expand Down

0 comments on commit dd3333f

Please sign in to comment.