/** * Returns the user's OpenID 2.0 verification page. * * @see SimpleID\Base\UserModule::user() */ public function userJSON($f3, $params) { $mgr = ModuleManager::instance(); $iss = $mgr->getModule('SimpleID\\Protocols\\Connect\\ConnectModule')->getCanonicalHost(); $store = StoreManager::instance(); $user = $store->loadUser($params['uid']); if ($user != NULL) { header('Content-Type: application/json'); print json_encode(array('iss' => $iss)); } else { $this->f3->status(404); $this->fatalError($this->t('User %uid not found.', array('%uid' => $uid))); } }
/** * Creates a module. * * This default constructor performs the following: * * - sets the {@link $logger} variable to the current logger * - sets the locale domain */ public function __construct() { $this->f3 = \Base::instance(); $this->logger = $this->f3->get('logger'); $mgr = ModuleManager::instance(); $info = $mgr->getModuleInfo(get_class($this)); if (isset($info['asset_domain'])) { $this->domain = $info['asset_domain']; } else { $this->domain = LocaleManager::DEFAULT_DOMAIN; } $this->f3->set('logout_label', $this->t('Log out')); $this->f3->set('footer_doc', $this->t('Documentation')); $this->f3->set('footer_support', $this->t('Support')); }
/** * The default route, called when the q parameter is missing or is invalid. * * This function performs the following: * * - This calls the index hook to determine whether other modules would handle this * request * - Otherwise, if MyModule is loaded, the dashboard is displayed * - If MyModule is not loaded, a blank page is displayed * */ public function index() { $mgr = ModuleManager::instance(); $this->logger->log(LogLevel::DEBUG, 'SimpleID\\Base\\IndexModule->index'); header('Vary: Accept'); $result = $mgr->invokeAll('index', $_REQUEST); if ($result) { return; } $auth = AuthManager::instance(); if (!$auth->isLoggedIn()) { $auth_module = $mgr->getModule('SimpleID\\Auth\\AuthModule'); $auth_module->loginForm(); } elseif ($mgr->isModuleLoaded('SimpleID\\Base\\MyModule')) { $this->f3->mock('GET /my/dashboard'); } else { $tpl = new \Template(); $this->f3->set('user_header', true); $this->f3->set('title', 'SimpleID'); print $tpl->render('page.html'); } }
/** * Returns the user's public page. * * @param string $uid the user ID */ function user($f3, $params) { $web = \Web::instance(); $tpl = \Template::instance(); $store = StoreManager::instance(); $mgr = ModuleManager::instance(); $this->f3->set('title', $this->t('User Page')); if (!isset($params['uid'])) { $this->f3->status(400); $this->f3->set('message', $this->t('No user specified.')); } else { $user = $store->loadUser($params['uid']); if ($user == NULL) { $this->f3->status(404); $this->f3->set('message', $this->t('User %uid not found.', array('%uid' => $params['uid']))); } else { header('Vary: Accept'); $content_type = $web->acceptable(array('text/html', 'application/xml', 'application/xhtml+xml', 'application/xrds+xml', 'application/json')); if ($content_type == 'application/xrds+xml' && $mgr->isModuleLoaded('SimpleID\\Protocols\\OpenID\\OpenIDModule')) { $mgr->getModule('SimpleID\\Protocols\\OpenID\\OpenIDModule')->userXRDS($f3, $params); return; } elseif ($content_type == 'application/json' && $mgr->isModuleLoaded('SimpleID\\Protocols\\Connect\\OpenID2MigrationModule')) { $mgr->getModule('SimpleID\\Protocols\\Connect\\OpenID2MigrationModule')->userJSON($f3, $params); } else { $xrds_location = $this->getCanonicalURL('@openid_user_xrds'); header('X-XRDS-Location: ' . $xrds_location); $this->f3->set('message', $this->t('This is the user %uid\'s SimpleID page. It contains hidden information for the use by OpenID consumers.', array('%uid' => $params['uid']))); $this->f3->set('title', $user['uid']); $this->f3->set('xrds', $xrds_location); if ($user->hasLocalOpenIDIdentity()) { $this->f3->set('local_id', $user["identity"]); } $this->f3->set('head', 'openid_head.html'); } } } print $tpl->render('page.html'); }
private function toSecureArray($hidden_value = null) { $mgr = ModuleManager::instance(); $copy = new ArrayWrapper($this->container); $secret_paths = $mgr->invokeAll('secretUserDataPaths'); if ($secret_paths == null) { $secret_paths = array(); } $secret_paths[] = 'uid'; foreach ($secret_paths as $path) { if ($hidden_value) { $copy->pathSet($path, $hidden_value); } else { $copy->pathUnset($path); } } return $copy->toArray(); }
/** * Selects the upgrade functions applicable for this upgrade. * * The upgrade functions are specified by the `upgradeList` * hook. This variable is an associative array containing version numbers * as keys and an array of upgrade function names as values. This function * merges all the upgrade function names of the version between the current * installed version and the upgraded version. * * @param string $version the version of SimpleID to upgrade from, calls * {@link getVersion()} if not specified * @return array an array of strings, containing the list of upgrade functions * to call. The functions should be called in the same order as they appear * in this array * @see SimpleID\API\ModuleHooks::upgradeListHook() */ protected function getUpgradeList($version = NULL) { $mgr = ModuleManager::instance(); $upgrade_data = array(); foreach ($mgr->getModules() as $name => $module) { $data = $mgr->invoke($name, 'upgradeList'); if ($data != NULL) { $upgrade_data = array_merge_recursive($upgrade_data, $data); } } if ($version == NULL) { $version = $this->getVersion(); } $list = array(); // Sorts versions from newest to oldest $versions = array_keys($upgrade_data); $versions = Semver::rsort($versions); foreach ($versions as $upgrade_version) { if (Comparator::lessThan($version, $upgrade_version)) { $list = array_merge($list, $upgrade_data[$upgrade_version]); } } if (Comparator::lessThan($version, SIMPLEID_VERSION)) { $list[] = 'SimpleID\\Upgrade->setVersion'; } return $list; }
/** * Generic function to display a page comprising blocks returned * from a hook. * * @param string $title the page title * @param string $hook the hook to call */ protected function blocksPage($title, $hook) { // Require HTTPS, redirect if necessary $this->checkHttps('redirect', true); $mgr = ModuleManager::instance(); $blocks = $mgr->invokeAll($hook); uasort($blocks, function ($a, $b) { if ($a['weight'] == $b['weight']) { return 0; } return $a['weight'] < $b['weight'] ? -1 : 1; }); $tpl = new \Template(); $this->f3->set('blocks', $blocks); $this->f3->set('title', $title); $this->f3->set('layout', 'my_blocks.html'); print $tpl->render('page.html'); }
public function __construct() { parent::__construct(); $this->oauth = OAuthManager::instance(); $this->mgr = ModuleManager::instance(); }
public function __construct() { $this->f3 = Base::instance(); $this->logger = $this->f3->get('logger'); $this->mgr = ModuleManager::instance(); }
/** * Displays the OpenID Connect configuration file for this installation. * */ public function openid_configuration() { $mgr = ModuleManager::instance(); header('Content-Type: application/json'); header('Content-Disposition: inline; filename=openid-configuration'); $scopes = $mgr->invokeAll('scopes'); $jwt_signing_algs = AlgorithmFactory::getSupportedAlgs(Algorithm::SIGNATURE_ALGORITHM); $jwt_encryption_algs = AlgorithmFactory::getSupportedAlgs(Algorithm::KEY_ALGORITHM); $jwt_encryption_enc_algs = AlgorithmFactory::getSupportedAlgs(Algorithm::ENCRYPTION_ALGORITHM); $claims_supported = array('sub', 'iss', 'auth_time', 'acr'); foreach ($scopes['oauth'] as $scope => $settings) { if (isset($settings['claims'])) { $claims_supporteds = array_merge($claims_supported, $settings['claims']); } } $token_endpoint_auth_methods_supported = array('client_secret_basic', 'client_secret_post'); $config = array('issuer' => $this->getCanonicalHost(), 'authorization_endpoint' => $this->getCanonicalURL('@oauth_auth', '', 'https'), 'token_endpoint' => $this->getCanonicalURL('@oauth_token', '', 'https'), 'userinfo_endpoint' => $this->getCanonicalURL('@connect_userinfo', '', 'https'), 'jwks_uri' => $this->getCanonicalURL('@connect_jwks', '', 'https'), 'scopes_supported' => array_keys($scopes['oauth']), 'response_types_supported' => array('code', 'token', 'id_token', 'id_token token', 'code token', 'code id_token', 'code id_token token'), 'response_modes_supported' => Response::getResponseModesSupported(), 'grant_types_supported' => array('authorization_code', 'refresh_token'), 'acr_values_supported' => array(), 'subject_types_supported' => array('public', 'pairwise'), 'userinfo_signing_alg_values_supported' => $jwt_signing_algs, 'userinfo_encryption_alg_values_supported' => $jwt_encryption_algs, 'userinfo_encryption_enc_alg_values_supported' => $jwt_encryption_enc_algs, 'id_token_signing_alg_values_supported' => $jwt_signing_algs, 'id_token_encrpytion_alg_values_supported' => $jwt_encryption_algs, 'id_token_encrpytion_enc_alg_values_supported' => $jwt_encryption_enc_algs, 'request_object_signing_alg_values_supported' => array_merge($jwt_signing_algs, array('none')), 'request_object_encryption_alg_values_supported' => $jwt_encryption_algs, 'request_object_encryption_enc_alg_values_supported' => $jwt_encryption_enc_algs, 'token_endpoint_auth_methods_supported' => $token_endpoint_auth_methods_supported, 'claim_types_supported' => array('normal'), 'claims_supported' => $claims_supported, 'claims_parameter_supported' => true, 'request_parameter_supported' => true, 'request_uri_parameter_supported' => true, 'require_request_uri_registration' => false, 'service_documentation' => 'http://simpleid.koinic.net/docs/'); $config = array_merge($config, $mgr->invokeAll('connectConfiguration')); print json_encode($config); }
function __construct() { parent::__construct(); $this->cache = \Cache::instance(); $this->mgr = ModuleManager::instance(); }