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

dav_endpoint_version not detected properly on ownCloud 10.8.0 #273

Open
cs-1 opened this issue Oct 14, 2021 · 1 comment
Open

dav_endpoint_version not detected properly on ownCloud 10.8.0 #273

cs-1 opened this issue Oct 14, 2021 · 1 comment

Comments

@cs-1
Copy link

cs-1 commented Oct 14, 2021

Hi all,

I'm trying to drop a file to a public, password protected share:

oc = owncloud.Client.from_public_link(url, folder_password=password)
oc.drop_file(file)

When debugging I can see that the path accessed is /public.php/webdav... which is incorrect for OC 10.8.0. Looking at the code I can see that there's a parameter dav_endpoint_version which should influence the path that is used. However, using oc = owncloud.Client.from_public_link(url, folder_password=password, dav_endpoint_version=1) doesn't do anything useful. Is this a bug or am I doing something wrong? Can you give me a hint? Thanks for your help!

@cs-1
Copy link
Author

cs-1 commented Oct 15, 2021

I looked deeper into the code and found that the problem lies here:

def anon_login(self, folder_token, folder_password=''):
self._session = requests.session()
self._session.verify = self._verify_certs
self._session.auth = (folder_token, folder_password)
url_components = parse.urlparse(self.url)
self._davpath = url_components.path + 'public.php/webdav'
self._webdav_url = self.url + 'public.php/webdav'

The code doesn't work for the latest ownCloud versions it seems. I'm no ownCloud expert so I don't know exactly why but calling self._update_capabilities() doesn't work for public links with password. So this doesn't seem to be an option like it is in login(). The only way to deal with this from my (naive) point of view is by patching anon_login something like this:

    def anon_login(self, folder_token, folder_password=''):
        self._session = requests.session()
        self._session.verify = self._verify_certs
        if self._dav_endpoint_version != 1:
            user = folder_token
        else:
            user = "public"
        self._session.auth = (user, folder_password)
        
        url_components = parse.urlparse(self.url)
        if self._dav_endpoint_version != 1:
            self._davpath = url_components.path + 'public.php/webdav'
            self._webdav_url = self.url + 'public.php/webdav'
        else:
            self._davpath = url_components.path + 'remote.php/dav/public-files/' +  folder_token
            self._webdav_url = self.url + 'remote.php/dav/public-files/' +  folder_token

This way, setting the parameter dav_endpoint_version=1 will call the correct path / URL with the correct username and password. This works for me but I don't know if that's the right way to do it. Someone with more OC experience should have a look whether or not there's some other way to do a self._update_capabilities() call for public links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant