xref: /plugin/oauthgeneric/Generic.php (revision 51298b298fbac4a06fe6f3b035130f21c919c74a)
1cf22df2fSAndreas Gohr<?php
2cf22df2fSAndreas Gohr
3cf22df2fSAndreas Gohrnamespace dokuwiki\plugin\oauthgeneric;
4cf22df2fSAndreas Gohr
5cf22df2fSAndreas Gohruse dokuwiki\plugin\oauth\Service\AbstractOAuth2Base;
6cf22df2fSAndreas Gohruse OAuth\Common\Http\Uri\Uri;
7cf22df2fSAndreas Gohr
8cf22df2fSAndreas Gohr/**
9cf22df2fSAndreas Gohr * Custom Service for Generic oAuth
10cf22df2fSAndreas Gohr */
11cf22df2fSAndreas Gohrclass Generic extends AbstractOAuth2Base
12cf22df2fSAndreas Gohr{
13d13c9ae1SPietro Saccardi    /** @inheritdoc */
14d13c9ae1SPietro Saccardi    public function needsStateParameterInAuthUrl() {
15*51298b29SPietro Saccardi        $plugin = plugin_load('helper', 'oauthgeneric');
16*51298b29SPietro Saccardi        return 0 !== $plugin->getConf('needs-state');
17d13c9ae1SPietro Saccardi    }
18cf22df2fSAndreas Gohr
19cf22df2fSAndreas Gohr    /** @inheritdoc */
20cf22df2fSAndreas Gohr    public function getAuthorizationEndpoint()
21cf22df2fSAndreas Gohr    {
22cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
23cf22df2fSAndreas Gohr        return new Uri($plugin->getConf('authurl'));
24cf22df2fSAndreas Gohr    }
25cf22df2fSAndreas Gohr
26cf22df2fSAndreas Gohr    /** @inheritdoc */
27cf22df2fSAndreas Gohr    public function getAccessTokenEndpoint()
28cf22df2fSAndreas Gohr    {
29cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
30cf22df2fSAndreas Gohr        return new Uri($plugin->getConf('tokenurl'));
31cf22df2fSAndreas Gohr    }
32cf22df2fSAndreas Gohr
33cf22df2fSAndreas Gohr    /**
34cf22df2fSAndreas Gohr     * @inheritdoc
35cf22df2fSAndreas Gohr     */
36cf22df2fSAndreas Gohr    protected function getAuthorizationMethod()
37cf22df2fSAndreas Gohr    {
38cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
39cf22df2fSAndreas Gohr
40f9e0a85cSAnna Dabrowska        return (int) $plugin->getConf('authmethod');
41cf22df2fSAndreas Gohr    }
42cf22df2fSAndreas Gohr}
43