trying to use nextcloud OAuth2 with Doorkeeper as it
jzahraoui opened this issue · 4 comments
Hello,
just want to if is something planned to support nextcloud OAuth2.
the documentation is here if needed :
https://docs.nextcloud.com/server/18/admin_manual/configuration_server/oauth2.html
I tried to use Doorkeeper provider but the callback seems to not working. I'm getting a HTTP 500 on this url:
https://<DOKUWIKI_URL>/doku.php?state=&code=xxxxxxxxxxx
thank you
Thank you for opening this issue.
CosmoCode is a software company in Berlin providing services for wiki, app and web development. As such we can't guarantee quick responses for issues opened on our Open Source projects.
If you require certain features or bugs fixed, you can always hire us. Feel free to contact us at dokuwiki@cosmocode.de for an offer.
can provide this logs from front server :
2020/03/21 16:19:25 [error] 354073#354073: *54907 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught OAuth\Common\Storage\Exception\TokenNotFoundException: No state found in storage in /var/lib/dokuwiki/lib/plugins/oauth/classes/oAuthStorage.php:149 Stack trace: #0 /var/lib/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(277): OAuth\Plugin\oAuthStorage->retrieveAuthorizationState('Generic') #1 /var/lib/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(255): OAuth\OAuth2\Service\AbstractService->retrieveAuthorizationState() #2 /var/lib/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(103): OAuth\OAuth2\Service\AbstractService->validateAuthorizationState('') #3 /var/lib/dokuwiki/lib/plugins/oauth/classes/AbstractAdapter.php(107): OAuth\OAuth2\Service\AbstractService->requestAccessToken('xxxxxxx...', '') #4 /var/lib/dokuwiki/lib/plugins/oauth/auth.php(96): OAuth\Plugin\AbstractAdapter->checkToken() #5 /usr/share/dokuwiki/inc/auth.php(101): auth_plug" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: <DOKUWIKI_HOST>, request: "GET /doku.php?state=&code=xxxHTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "<DOKUWIKI_HOST>"
I have the same problem. Here's the log (I manually formatted it a bit):
[Fri Jun 19 17:13:10.620623 2020] [php7:error] [pid 67] [client 10.0.0.2:39080] PHP Fatal error:
Uncaught OAuth\Common\Storage\Exception\TokenNotFoundException:
No state found in storage in /bitnami/dokuwiki/lib/plugins/oauth/classes/oAuthStorage.php:149
Stack trace:
#0 /bitnami/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(279): OAuth\Plugin\oAuthStorage->retrieveAuthorizationState('Generic')
#1 /bitnami/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(257): OAuth\OAuth2\Service\AbstractService->retrieveAuthorizationState()
#2 /bitnami/dokuwiki/lib/plugins/oauth/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php(103): OAuth\OAuth2\Service\AbstractService->validateAuthorizationState('')
#3 /bitnami/dokuwiki/lib/plugins/oauth/classes/AbstractAdapter.php(107): OAuth\OAuth2\Service\AbstractService->requestAccessToken('xxxxxx', '')
#4 /bitnami/dokuwiki/lib/plugins/oauth/auth.php(96): OAuth\Plugin\AbstractAdapter->checkToken()
#5 /opt/bitnami/dokuwiki/inc/auth.php(101): auth_plugin_oauth->trustExternal('', '', false)
#6 /opt/bitn in /bitnami/dokuwiki/lib/plugins/oauth/classes/oAuthStorage.php on line 149, referer: http://www.example.com/
I tried modifying the classes/oAuthStorage.php
like this:
public function retrieveAuthorizationState($service) {
$data = $this->loadServiceFile($service);
if(!isset($data['state'])) {
// throw new TokenNotFoundException('No state found in storage'); // <-- remove this line
return ''; // <-- add this line
}
return $data['state'];
}
and change the permission of the file $DOKUWIKI_HOME/conf/users.auth.php
to 666, and it works, though I suspect that 666 is too insecure.
a nextcloud adapter can now be implemented as separate plugin