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

Add Webdav-Location header in private link redirect #30383

Merged
merged 1 commit into from
Feb 6, 2018

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Feb 6, 2018

Description

Added Webdav-Location header in response when opening private links.
Added 404 status code for error page when requesting inaccessible/invalid private links.

Related Issue

Similar to #28615

Motivation and Context

Useful for clients to resolve private links to Webdav URLs without having to extract the file id from the URL. Please note that there are at least two permalink formats, one with "/f/$fileId" and another one is the link when copied directly from the browser which has "fileid=$fileId". This removes the need for clients to know about this format and simply query whatever link they got and get it resolved.

How Has This Been Tested?

Manual test with curl (with -I to only request headers with the "HEAD" method) and unit tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

cc @michaelstingl @nasli

Useful for clients to resolve private links to Webdav URLs without
having to extract the file id from the URL
@PVince81
Copy link
Contributor Author

PVince81 commented Feb 6, 2018

If a private link points to a file that is in trash, we don't have a matching Webdav URL yet until #15646 is implemented. Returning a 404 error would be wrong here.

@phil-davis
Copy link
Contributor

Backport stable10 #30387

return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
$response = new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
if ($isFilesView) {
$webdavUrl = $this->urlGenerator->linkTo('', 'remote.php') . '/dav/files/' . $uid . '/';

Choose a reason for hiding this comment

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

@PVince81 shouldn't this be endpoint-aware instead of hardcoded? i.e. using the same endpoint as the request that originated this $response? My endpoint-juggling context might be playing mind tricks on me, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

endpoint-aware in what way ?

The ViewController is not part of Webdav but it's the web page from "index.php/apps/files" so what decision do you think should be made based on this ?

Choose a reason for hiding this comment

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

it's the web page from "index.php/apps/files"

You're right. I was thinking on a different (non-existent) workflow.

What I really meant was If there won't be a problem to use a hardcoded WebDAV path regardless of what the client that is accessing the private link normally uses/understands.

e.g. since this request came from the iOS team and they talk with the old endpoint, the new might offer different properties, no? Or if, like in the past; we detect some problems with the endpoint on the webUI that forces us to temporarily switch back to old, etc.

$response = new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
if ($isFilesView) {
$webdavUrl = $this->urlGenerator->linkTo('', 'remote.php') . '/dav/files/' . $uid . '/';
$webdavUrl .= ltrim($baseFolder->getRelativePath($file->getPath()), '/');

Choose a reason for hiding this comment

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

@PVince81 take into account that the file name at this point is not URL-encoded: a file called level7$éâ .txt should point to remote.php/dav/files/user/Documents/level7$%C3%A9%C3%A2%20.txt but header is Webdav-Location: /remote.php/dav/files/user/Documents/level7$éâ .txt.

Clients will query a non-existent file then. We should add a test for it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, I'll then add some encoding in a subsequent PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we go, please have a look: #30503

@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants