Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewire dav files endpoint to home #1120

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/ocdav-dav-files-to-home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Rewire dav files to the home storage

If the user specified in the dav files URL matches the current one,
rewire it to use the webDavHandler which is wired to the home storage.

This fixes path mapping issues.

https://github.com/cs3org/reva/pull/1120
27 changes: 27 additions & 0 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,36 @@ func (s *svc) Handler() http.Handler {
// oc uses /dav/files/$user -> /$home/$user/...
// for oc we need to prepend the path to user homes
// or we take the path starting at /dav and allow rewriting it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR finally addresses the above comments. The /webdav and dav/files/ endpoints need to show the same tree for a user. /dav/files/ can also use the userid for other users, which is currently forbidden by oc10 but for ocis access is in theory possible using the eos driver because access is based on acls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@labkode how dous this fit with the way cern exposes projects at /webdav? Afaict this is better solved by the spaces concept we plan to introduce: an endpoint that iterates the storages a user has access to, as well as the quota, usage and root etag information.

parts := strings.SplitN(strings.Trim(r.URL.Path, "/"), "/", 3)
log.Debug().Interface("pathParts", parts).Msg("Checking user from path")
if len(parts) >= 2 && parts[0] == "files" && parts[1] != "" {
requestURLUserID := parts[1]
contextUser := ctxuser.ContextMustGetUser(ctx)
log.Debug().Str("contextUserId", contextUser.Id.OpaqueId).
Str("requestUrlUserId", requestURLUserID).
Msg("Checking user from URL")

if contextUser.Id.OpaqueId == requestURLUserID {
if len(parts) > 2 {
r.URL.Path = parts[2]
} else {
r.URL.Path = ""
}
log.Debug().Str("urlPath", r.URL.Path).Msg("Using webDavHandler")
// use webdav handler instead to mimic the "/webdav" endpoint
base = path.Join(base, "webdav")
ctx := context.WithValue(ctx, ctxKeyBaseURI, base)
r = r.WithContext(ctx)
s.webDavHandler.Handler(s).ServeHTTP(w, r)
return
}
}

base = path.Join(base, "dav")
ctx := context.WithValue(ctx, ctxKeyBaseURI, base)
r = r.WithContext(ctx)
log.Debug().Msg("Using davHandler")
s.davHandler.Handler(s).ServeHTTP(w, r)
return
}
Expand Down