Skip to content

Commit

Permalink
Public link propfind (#2315)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored Dec 6, 2021
1 parent ed9517b commit 147c0c2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/public-link-propfind.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("<oc:signature>")
sb.WriteString(ls.Signature.Signature)
sb.WriteString("</oc:signature>")
sb.WriteString("<oc:expiration>")
sb.WriteString(expiration.Format(time.RFC3339))
sb.WriteString("</oc:expiration>")

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
// <oc:privatelink>https://phoenix.owncloud.com/f/9</oc:privatelink>
fallthrough
Expand Down
3 changes: 0 additions & 3 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 147c0c2

Please sign in to comment.