/** * @param string $dictionaryName * @param string $translationName * @param array $translations */ private function includeTranslation($dictionaryName, $translationName, array $translations) { if (!isset($translations[$this->languageCode])) { return; } $translation = $translations[$this->languageCode]; $this->template->includeInlineTranslation($this->createTagForTranslation($dictionaryName, $translationName), $translation); }
} $liveClients = array(); foreach ($user['clients'] as $id) { $client = $clientStore->getClient($id); if (!is_null($client)) { array_push($clients, $client); array_push($liveClients, $client['id']); } } if (count($liveAuthorizationCodes) != count($user['authorizationCodes']) || count($liveRefreshTokens) != count($user['refreshTokens']) || count($liveAccessTokens) != count($user['accessTokens']) || count($liveClients) != count($user['clients'])) { $user['authorizationCodes'] = $liveAuthorizationCodes; $user['refreshTokens'] = $liveRefreshTokens; $user['accessTokens'] = $liveAccessTokens; $user['clients'] = $liveClients; $userStore->updateUser($user); } } $t = new SimpleSAML_XHTML_Template($globalConfig, 'oauth2server:manage/status.php'); $t->data['authorizationCodes'] = $authorizationCodes; $t->data['refreshTokens'] = $refreshTokens; $t->data['accessTokens'] = $accessTokens; if ($config->getValue('enable_client_registration', false)) { $t->data['clients'] = $clients; foreach ($clients as $client) { $t->includeInlineTranslation('{oauth2server:oauth2server:client_description_' . $client['id'] . '}', $client['description']); } } $t->data['statusForm'] = SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php'); $t->data['tokenForm'] = SimpleSAML_Module::getModuleURL('oauth2server/manage/token.php'); $t->data['clientForm'] = SimpleSAML_Module::getModuleURL('oauth2server/manage/client.php'); $t->show();
$token = $tokenStore->getRefreshToken($_REQUEST['tokenId']); if (is_array($token) && isset($_POST['revoke'])) { $tokenStore->removeRefreshToken($_REQUEST['tokenId']); SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php')); } } else { if (array_search($_REQUEST['tokenId'], $user['accessTokens']) !== false) { $token = $tokenStore->getAccessToken($_REQUEST['tokenId']); if (is_array($token) && isset($_POST['revoke'])) { $tokenStore->removeAccessToken($_REQUEST['tokenId']); SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php')); } } } } } $globalConfig = SimpleSAML_Configuration::getInstance(); $t = new SimpleSAML_XHTML_Template($globalConfig, 'oauth2server:manage/token.php'); foreach ($config->getValue('scopes', array()) as $scope => $translations) { $t->includeInlineTranslation('{oauth2server:oauth2server:' . $scope . '}', $translations); } if (isset($token)) { $clientStore = new sspmod_oauth2server_OAuth2_ClientStore($config); $client = $clientStore->getClient($token['clientId']); if (!is_null($client)) { $t->data['token'] = $token; $t->includeInlineTranslation('{oauth2server:oauth2server:client_description_text}', $client['description']); } } $t->data['form'] = SimpleSAML_Module::getModuleURL('oauth2server/manage/token.php'); $t->show();
} } else { if (array_key_exists('deny', $_REQUEST)) { $response = \sspmod_oauth2server_Utility_Uri::buildErrorResponse('access_denied', 'request denied by resource owner', 'CONSENT_NOT_GRANTED', array()); $response['error_uri'] = SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Module::getModuleURL('oauth2server/authorization/error.php'), $response); if (array_key_exists('state', $state)) { $response['state'] = $state['state']; } unset($response['error_code_internal']); unset($response['error_parameters_internal']); sspmod_oauth2server_Utility_Uri::redirectUri(sspmod_oauth2server_Utility_Uri::addQueryParametersToUrl($state['returnUri'], $response)); } } $t = new SimpleSAML_XHTML_Template($globalConfig, 'oauth2server:authorization/consent.php'); foreach ($config->getValue('scopes', array()) as $scope => $translations) { $t->includeInlineTranslation('{oauth2server:oauth2server:' . $scope . '}', $translations); } $t->includeInlineTranslation('{oauth2server:oauth2server:client_description}', array_key_exists('description', $client) ? $client['description'] : array('' => '')); $t->data['clientId'] = $state['clientId']; $t->data['stateId'] = $_REQUEST['stateId']; $t->data['scopes'] = array(); $scopes = isset($client['scope']) ? $client['scope'] : array(); foreach ($state['requestedScopes'] as $scope) { $t->data['scopes'][$scope] = isset($scopes[$scope]) && $scopes[$scope]; } $t->data['form'] = SimpleSAML_Module::getModuleURL('oauth2server/authorization/consent.php'); foreach ($tokenTTLs as $ttl => $translations) { $t->includeInlineTranslation('{oauth2server:oauth2server:ttl_' . $ttl . '}', $translations); } $t->data['ttlChoices'] = array_keys($tokenTTLs); $t->data['ttlDefault'] = $t->data['ttlChoices'][0];