diff --git a/changelog/unreleased/public-link-propfind.md b/changelog/unreleased/public-link-propfind.md new file mode 100644 index 0000000000..d2809bbdb0 --- /dev/null +++ b/changelog/unreleased/public-link-propfind.md @@ -0,0 +1,6 @@ +Enhancement: Add new attributes to public link propfinds + +Added a new property "oc:signature-auth" to public link propfinds. +This is a necessary change to be able to support archive downloads in password protected public links. + +https://github.com/cs3org/reva/pull/2315 diff --git a/internal/http/services/owncloud/ocdav/propfind.go b/internal/http/services/owncloud/ocdav/propfind.go index e1c43146b6..320049dfe1 100644 --- a/internal/http/services/owncloud/ocdav/propfind.go +++ b/internal/http/services/owncloud/ocdav/propfind.go @@ -847,6 +847,24 @@ func (s *svc) mdToPropResponse(ctx context.Context, pf *propfindXML, md *provide } else { propstatNotFound.Prop = append(propstatNotFound.Prop, s.newProp("oc:"+pf.Prop[i].Local, "")) } + case "signature-auth": + if isPublic { + // We only want to add the attribute to the root of the propfind. + if strings.HasSuffix(md.Path, ls.Token) && ls.Signature != nil { + expiration := time.Unix(int64(ls.Signature.SignatureExpiration.Seconds), int64(ls.Signature.SignatureExpiration.Nanos)) + var sb strings.Builder + sb.WriteString("") + sb.WriteString(ls.Signature.Signature) + sb.WriteString("") + sb.WriteString("") + sb.WriteString(expiration.Format(time.RFC3339)) + sb.WriteString("") + + propstatOK.Prop = append(propstatOK.Prop, s.newPropRaw("oc:signature-auth", sb.String())) + } else { + propstatNotFound.Prop = append(propstatNotFound.Prop, s.newProp("oc:signature-auth", "")) + } + } case "privatelink": // phoenix only // https://phoenix.owncloud.com/f/9 fallthrough diff --git a/internal/http/services/owncloud/ocdav/publicfile.go b/internal/http/services/owncloud/ocdav/publicfile.go index b369f6650b..ed75e31672 100644 --- a/internal/http/services/owncloud/ocdav/publicfile.go +++ b/internal/http/services/owncloud/ocdav/publicfile.go @@ -181,9 +181,6 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s w.WriteHeader(http.StatusNotFound) return } - // adjust path - tokenStatInfo.Path = path.Join("/", tokenStatInfo.Path, path.Base(pathRes.Path)) - infos := s.getPublicFileInfos(onContainer, depth == "0", tokenStatInfo) propRes, err := s.multistatusResponse(ctx, &pf, infos, ns, nil)