xref: /plugin/oauthgeneric/Generic.php (revision d13c9ae11cd8e21d2fe26f3884884b72a61489f2)
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{
13*d13c9ae1SPietro Saccardi    /** @inheritdoc */
14*d13c9ae1SPietro Saccardi    public function needsStateParameterInAuthUrl() {
15*d13c9ae1SPietro Saccardi        return true;
16*d13c9ae1SPietro Saccardi    }
17cf22df2fSAndreas Gohr
18cf22df2fSAndreas Gohr    /** @inheritdoc */
19cf22df2fSAndreas Gohr    public function getAuthorizationEndpoint()
20cf22df2fSAndreas Gohr    {
21cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
22cf22df2fSAndreas Gohr        return new Uri($plugin->getConf('authurl'));
23cf22df2fSAndreas Gohr    }
24cf22df2fSAndreas Gohr
25cf22df2fSAndreas Gohr    /** @inheritdoc */
26cf22df2fSAndreas Gohr    public function getAccessTokenEndpoint()
27cf22df2fSAndreas Gohr    {
28cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
29cf22df2fSAndreas Gohr        return new Uri($plugin->getConf('tokenurl'));
30cf22df2fSAndreas Gohr    }
31cf22df2fSAndreas Gohr
32cf22df2fSAndreas Gohr    /**
33cf22df2fSAndreas Gohr     * @inheritdoc
34cf22df2fSAndreas Gohr     */
35cf22df2fSAndreas Gohr    protected function getAuthorizationMethod()
36cf22df2fSAndreas Gohr    {
37cf22df2fSAndreas Gohr        $plugin = plugin_load('helper', 'oauthgeneric');
38cf22df2fSAndreas Gohr
39f9e0a85cSAnna Dabrowska        return (int) $plugin->getConf('authmethod');
40cf22df2fSAndreas Gohr    }
41cf22df2fSAndreas Gohr}
42