WebDAV cloud storage

Similar to how Hubzilla and Misskey integrate a small cloud drive, this would be a nice add-on for Akkoma.

I don’t think it makes much sense to integrate into the core though, so I looked at external options.

There is a nice lightweight WebDav server called Karadav that at least for me ticks all the boxes.

I installed it yesterday and with some minor caveats it is working great. I also wrote a small php script for it based on the Ejabberd akkoma integration to allow using the Akkoma accounts with it. I’ll test it a bit more and then share here.

Ultimately it would be nice if I could also add a small sidebar widget or so to Akkoma-fe to allow interacting with this WebDAV storage directly from Akkoma. Let’s see if I can find a good option for that.

1 Like

After some bugs got fixed upstream this seems to be working well.

To make Akkoma accounts work all you need to do is to configure this in the main config file:

const AUTH_CALLBACK = ['akkoma_auth', 'login'];

and then add an akkoma_auth.php file with the following content in the /lib folder of Karadav:

<?php
class akkoma_auth {
        static function login(string $user, string $password) {
        $url = 'http://127.0.0.1:4000/api/v1/accounts/verify_credentials';
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_TIMEOUT, 3); //timeout after 3 seconds
        curl_setopt($ch, CURLOPT_USERPWD, $user . ":" . $password);
        curl_exec($ch);
        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   //get status code
        return ($status_code == 200);
        }
}

This works if Akkoma is on the same server. Linking to a remote server is also possible, but if you leave the local network it is strongly recommended to use https:// in the $url parameter as otherwise the credentials are transmitted in (b64 scrambled) clear-text.

No idea if this is good practise or even good php code, but it works (might need php8.x though). The idea is based on the Ejabberd auth script from the official Akkoma documentation.

I am still having some issues with CORS for accessing the webdav storage through an external JS client and the Android Nextcloud app is also still not accepting my Karadav server (probably some .well-known missing?) but I got a lot of nice other Webdav apps to work with it already.

2 Likes