Forum

Pydio API not working through Hiawatha

alexpacio
13 November 2015, 11:27
Hi,
if I try to connect my PydioSync client with a Pydio installation hosted by Hiawatha I get a 404 error. It seems to be a rewrite rule miss but I can't manage how to fix it.

PydioSync leverages on API, they are called through the page api.php

thanks in advance
Hugo Leisink
13 November 2015, 12:53
I don't know Pydio that well. Do you have an Apache rewrite rule that I can convert?
alexpacio
13 November 2015, 13:06
Hi,
here is the Apache .htaccess file:
<IfModule mod_rewrite.c>
# You must set the correct values here if you want
# to enable webDAV sharing. The values assume that your
# Pydio installation is at http://yourdomain/
# and that you want the webDAV shares to be accessible via
# http://yourdomain/shares/repository_id/
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]
RewriteRule ^user ./index.php?get_action=user_access_point [L]
RewriteCond %{REQUEST_URI} !^/index
RewriteCond %{REQUEST_URI} !^/plugins
RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/welcome|^/ws-
RewriteRule (.*) index.php [L]

#Following lines seem to be necessary if PHP is working
#with apache as CGI or FCGI. Just remove the #
#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi

#RewriteCond %{HTTP:Authorization} ^(.*)
#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

#Following lines may be necessary for a PHP-FPM setup
# to make sure that authorization is transmitted.
# Just remove the # at the beginning of the line

#SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

</IfModule>

AddType application/json .json



Here is my URL Toolkit:
UrlToolkit {
ToolkitID = pydio
# Do Call scannerblocker
# Do Call vulnerabilityblocker
Match ^/public Rewrite /data/public/share.php?hash=$1
Match ^/data DenyAccess
RequestURI exists Return
Match ^/shares Rewrite /dav.php
Match ^/api Rewrite /rest.php
Match ^/user Rewrite /index.php?get_action=user_access_point
}
alexpacio
14 November 2015, 12:30
Hi Hugo,

it seems that, every URL that is longer than the prefixes matched by the URL toolkit are dropped.

Here I could manage correctly API calls, but it remains to get WebDAV working. WebDAV in Pydio works leveraging on SabreDAV, which can be called through the /shares suffix.
UrlToolkit {
ToolkitID = pydio
Do Call scannerblocker
Do Call vulnerabilityblocker
Match ^/public Rewrite /data/public/share.php?hash=$1
Match ^/data DenyAccess
RequestURI exists Return
Match ^/shares Rewrite /dav.php
Match ^/api/(.*)\?(.*) Rewrite /rest.php?id=$1&$2
Match ^/api/(.*) Rewrite /rest.php?id=$1
Match ^/api Rewrite /rest.php
Match ^/user Rewrite /index.php?get_action=user_access_point
Match .* Rewrite /index.php
}


Just hope that you can help me to understand how to correctly translate this Apache rewrite rule.

Thanks in advance,
Alessandro
Hugo Leisink
15 November 2015, 18:36
The Hiawatha version of
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]
RewriteRule ^user ./index.php?get_action=user_access_point [L]
RewriteCond %{REQUEST_URI} !^/index
RewriteCond %{REQUEST_URI} !^/plugins
RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/welcome|^/ws-
RewriteRule (.*) index.php [L]

is
RequestURI exists Return
Match ^/shares Rewrite /dav.php
Match ^/api Rewrite /rest.php
Match ^/user Rewrite /index.php?get_action=user_access_point
Match ^/(dashboard|settings|welcome\ws-).* Rewrite /index.php
alexpacio
16 November 2015, 09:41
Hi Hugo,
API data exchange in Pydio still doesn't work with this URL Toolkit.

http://pydio.domain.com/api/default/changes/0

should return a message, while it returns a 404 instead.

Even WebDAV through /shares shows only on the root folder. If I go deeper (so, if I try to visit a suburl of /shares) , I get a 404.

I saw that, for example, this two additions on the toolkit:
Match ^/api/(.*)\?(.*) Rewrite /rest.php?id=$1&$2
Match ^/api/(.*) Rewrite /rest.php?id=$1

Make api working correctly, as it seems in a first test.

It remains to make WebDAV shares working. (WebDAV on Pydio doesn't rely on webserver webdav but it uses SabreDAV which is a PHP implementation of WebDAV instead).
alexpacio
18 November 2015, 21:20
Hi,
is there something I can do in order to make WebDAV working on Pydio?
Hugo Leisink
21 November 2015, 17:52
What is needed to make it work?
alexpacio
25 November 2015, 17:05
I think that it is needed one more rule on the URL toolkit that can process not only the absolute URL calls like this:
http://example.com/shares
but also what is under shares, like:
http://example.com/shares/ws-workspace/...

And the toolkit you provided is not working in this way. I can only see the absolute "shares" URL, otherwise I get an error from the webserver.
This topic has been closed.