12 require_once (CH_DIRECTORY_PATH_PLUGINS .
'OAuth2/Autoloader.php');
26 'client_table' =>
'ch_oauth_clients',
27 'access_token_table' =>
'ch_oauth_access_tokens',
28 'refresh_token_table' =>
'ch_oauth_refresh_tokens',
29 'code_table' =>
'ch_oauth_authorization_codes',
30 'user_table' =>
'Profiles',
33 'scope_table' =>
'ch_oauth_scopes',
34 'public_key_table' =>
'',
40 'require_exact_redirect_uri' =>
false,
44 $this->_oServer->addGrantType(
new OAuth2\GrantType\ClientCredentials($this->_oStorage));
47 $this->_oServer->addGrantType(
new OAuth2\GrantType\AuthorizationCode($this->_oStorage));
54 $this->_oServer->handleTokenRequest(
OAuth2\Request::createFromGlobals())->send();
60 if (!$this->_oServer->verifyResourceRequest(
OAuth2\Request::createFromGlobals())) {
61 $this->_oServer->getResponse()->send();
65 $aToken = $this->_oServer->getAccessTokenData(
OAuth2\Request::createFromGlobals());
73 $this->_oAPI->errorOutput(404,
'not_found',
'No such API endpoint available');
77 $sScope = $this->_oAPI->aAction2Scope[
$sAction];
78 if (
false === strpos($sScope, $aToken[
'scope'])) {
79 $this->_oAPI->errorOutput(403,
'insufficient_scope',
'The request requires higher privileges than provided by the access token');
83 $this->_oAPI->$sAction($aToken);
94 if (!$this->_oServer->validateAuthorizeRequest($oRequest, $oResponse)) {
95 $o = json_decode($oResponse->getResponseBody());
96 $this->_oTemplate->pageError(
$o->error_description);
100 $_REQUEST[
'relocate'] = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'auth/?client_id=' .
ch_get(
'client_id') .
'&response_type=' .
ch_get(
'response_type') .
'&state=' .
ch_get(
'state') .
'&redirect_uri=' .
ch_get(
'redirect_uri');
101 login_form(
'', 0,
false,
'disable_external_auth no_join_text');
106 $this->_oTemplate->pageAuth($this->_oDb->getClientTitle(
ch_get(
'client_id')));
113 $this->_oServer->handleAuthorizeRequest($oRequest, $oResponse, $bConfirm,
$iProfileId);
121 $this->_oTemplate->displayAccessDenied ();
125 $this->_oTemplate->pageStart();
133 if (
$oForm->isSubmittedAndValid ()) {
142 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
_t(
'_ch_oauth_add'));
145 if (is_array($_POST[
'clients']) && $_POST[
'clients'])
146 $this->_oDb->deleteClients($_POST[
'clients']);
149 'ch-oauth-delete' =>
_t(
'_Delete'),
152 $aClients = $this->_oDb->getClients();
154 'ch_repeat:clients' => $aClients,
155 'controls' => $sControls,
157 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'clients',
$aVars),
_t(
'_ch_oauth_clients'));
161 'content' =>
_t(
'_ch_oauth_help_text', CH_WSB_URL_ROOT)
163 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
_t(
'_ch_oauth_help'));
166 $this->_oTemplate->addCssAdmin (
'forms_adv.css');
167 $this->_oTemplate->pageCodeAdmin (
_t(
'_ch_oauth_administration'));