From dd3333fb03d920cf0c740747a22a4e8c79f091fd Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte <39946305+gmgigi96@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:16:32 +0100 Subject: [PATCH] Fix expired authenticated public link error code (#3528) --- .../fix-authenticated-expired-publiclinks.md | 8 ++++++++ pkg/cbox/publicshare/sql/sql.go | 13 ++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/fix-authenticated-expired-publiclinks.md diff --git a/changelog/unreleased/fix-authenticated-expired-publiclinks.md b/changelog/unreleased/fix-authenticated-expired-publiclinks.md new file mode 100644 index 0000000000..3077947596 --- /dev/null +++ b/changelog/unreleased/fix-authenticated-expired-publiclinks.md @@ -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 \ No newline at end of file diff --git a/pkg/cbox/publicshare/sql/sql.go b/pkg/cbox/publicshare/sql/sql.go index 6f0da1294a..96f0e9168b 100644 --- a/pkg/cbox/publicshare/sql/sql.go +++ b/pkg/cbox/publicshare/sql/sql.go @@ -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 { @@ -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 }