Closed poVoq closed 1 year ago
Implemented, please test and report :)
I am trying this now, but both my code and the function example returns an error like this:
TypeError
call_user_func(): Argument #1 ($callback) must be a valid callback, function "my_login" not found or invalid function name
This is when I directly uncomment the function in the config file. I guess that is not possible.
Edit: making it a static function breaks karadav completely ;)
Ok I can get it somewhat to work with the class option when I add a MyAuthClass.php
into the /lib
folder with the following content:
<?php
class MyAuthClass {
static function login(string $user, string $password) {
return ($user == 'me' && $password == 'secret');
}
}
However this only works with the correct me
&& secret
. If you enter anything wrong the following error shows:
TypeError
KaraDAV\Users::login(): Return value must be of type ?stdClass, bool returned
which refers to the return false;
in /data/ssd/outmode/karadav/lib/KaraDAV/Users.php:170
Edit: this also works with my own auth code for Akkoma, but only if the correct user credentials are provided.
TypeError call_user_func(): Argument #1 ($callback) must be a valid callback, function "my_login" not found or invalid function name
It's because you put the my_login function in config.local.php which is in the KaraDAV namespace.
Fix it with: const AUTH_CALLBACK = 'KaraDAV\my_login';
KaraDAV\Users::login(): Return value must be of type ?stdClass, bool returned
Fixed thanks.
Seems all working now :+1: I shared my auth script for Akkoma here:
Would be nice if there was support for referencing small scripts to authenticate users against an API or an external database.
Specifically I would like to link this to my Fediverse instance similar to how it can be done with an XMPP server: https://docs.akkoma.dev/stable/configuration/integrations/howto_ejabberd/
(I am aware of the LDAP option, but it complicates user management too much otherwise).
Thanks!