本文整理汇总了PHP中SimpleSAML_Auth_Simple::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Auth_Simple::getAttributes方法的具体用法?PHP SimpleSAML_Auth_Simple::getAttributes怎么用?PHP SimpleSAML_Auth_Simple::getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSAML_Auth_Simple
的用法示例。
在下文中一共展示了SimpleSAML_Auth_Simple::getAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// Obligatoire
parent::__construct();
$this->data = array();
// System FED Oxylane
if (FEDACTIVE) {
require __DIR__ . '/../simplesaml/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('Oxylane-sp');
$isAuth = $as->isAuthenticated();
if (!$isAuth) {
$as->requireAuth();
} else {
$attributes = $as->getAttributes();
$this->data['fed']['0'] = $attributes['uid'][0];
//identifiant
$this->data['fed']['1'] = $attributes['cn'][0];
//nom de la personne
$this->data['fed']['2'] = $attributes['mail'][0];
//mail de la personne
}
} else {
$this->data['fed']['0'] = "ID";
$this->data['fed']['1'] = "NOM";
$this->data['fed']['2'] = "MAIL";
}
// END FED
// Chargement des ressources pour tout le contrôleur
$this->load->database();
$this->load->helper('form');
$this->load->helper('titreUrl');
$this->load->helper('convertlien');
$this->load->library('form_validation');
$this->load->model('pages_model', 'pm');
$this->load->model('plannings_model', 'plm');
$this->load->model('types_model', 'tm');
$this->load->model('chaines_model', 'cm');
$this->load->model('groupes_model', 'gm');
$this->load->model('bandeau_model', 'bm');
if (FEDLOG) {
$this->load->model('logs_model', 'lm');
}
// Récupération de toute les chaines
$this->data['chaines'] = $this->cm->getAll();
$this->data['superadmin'] = true;
// Cette méthode permet de changer les délimiteurs par défaut des messages d'erreur (<p></p>).
$this->form_validation->set_error_delimiters('<p class="alert alert-error fade in"><a class="close" data-dismiss="alert" href="#">×</a>', '</p>');
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
//return redirect()->guest('auth/login')
//tsipizic for SAML
//login user and get attributes
$as = new \SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
$attributes = $as->getAttributes();
//create user if he does not exist and log him in
$mail = $attributes['mail'][0];
$db_user = User::where('mail', $mail)->first();
if ($db_user) {
Auth::login($db_user);
} else {
$user = new User();
$user->mail = $mail;
$user->save();
Auth::login($user);
}
}
}
return $next($request);
}
示例3: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
if (!$request->getParameter('sf_culture')) {
$ssaml = new SimpleSAML_Auth_Simple('default-sp');
$attributes = $ssaml->getAttributes();
if ($this->getUser()->isFirstRequest()) {
if (array_key_exists('preferredLanguage', $attributes)) {
$culture = $attributes['preferredLanguage'];
if ($culture != 'hu' && $culture != 'en') {
$culture = $request->getPreferredCulture(array('en', 'hu'));
}
} else {
$culture = $request->getPreferredCulture(array('en', 'hu'));
}
$this->getUser()->setCulture($culture);
$this->getUser()->isFirstRequest(false);
} else {
$culture = $this->getUser()->getCulture();
}
$this->redirect('localized_homepage');
}
$p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
if ($p) {
$oos = $p->getOrganization();
$ros = $p->getRelatedOrganizations(TRUE);
} else {
$p = new Principal();
$p->setFedid($this->getUser()->getUsername());
$p->save();
}
$this->oos = $oos;
$this->ros = $ros;
}
示例4: get_attributes
function get_attributes()
{
// Only run in step 5 or later ! So change when steps array is changed!
if (isset($_REQUEST['s'])) {
if ($_REQUEST['s'] >= 4) {
if ($ssp_location = issetweb('ssp_location')) {
$ssp_autoloader = $ssp_location . '/lib/_autoload.php';
if (is_readable($ssp_autoloader)) {
//echo "<pre>sesion:"; var_dump($_SESSION); echo "rquest"; var_dump($_REQUEST);
include_once $ssp_autoloader;
if ($ssp_authsource = issetweb('ssp_authsource')) {
$as = new SimpleSAML_Auth_Simple($ssp_authsource);
if (!$as->isAuthenticated()) {
$as->requireAuth();
}
$attributes = $as->getAttributes();
foreach (array_keys($attributes) as $at) {
// These are key|value pairs to populate the SELECT boxes
$simpleattrs[$at] = $at . " (" . $attributes[$at][0] . ")";
}
// Add attributes themselves as well, for later use
$simpleattrs['saml'] = $attributes;
// echo "<pre>"; var_dump($simpleattrs);
ksort($simpleattrs);
return $simpleattrs;
}
}
}
}
}
return false;
}
示例5: authenticate
/**
* Performs an authentication attempt using SimpleSAMLphp
*
* @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
* @return Zend_Auth_Result
*/
public function authenticate()
{
require_once LIBRARY_PATH . '/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
// If SimpleSAMLphp didn't stop it, then the user is logged in.
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $as->getAttributes(), array("Authentication Successful"));
}
示例6: checkAccess
/**
* Check that the user has access to the statistics.
*
* If the user doesn't have access, send the user to the login page.
*/
public static function checkAccess(SimpleSAML_Configuration $statconfig)
{
$protected = $statconfig->getBoolean('protected', FALSE);
$authsource = $statconfig->getString('auth', NULL);
$allowedusers = $statconfig->getValue('allowedUsers', NULL);
$useridattr = $statconfig->getString('useridattr', 'eduPersonPrincipalName');
$acl = $statconfig->getValue('acl', NULL);
if ($acl !== NULL && !is_string($acl) && !is_array($acl)) {
throw new SimpleSAML_Error_Exception('Invalid value for \'acl\'-option. Should be an array or a string.');
}
if (!$protected) {
return;
}
if (SimpleSAML\Utils\Auth::isAdmin()) {
// User logged in as admin. OK.
SimpleSAML_Logger::debug('Statistics auth - logged in as admin, access granted');
return;
}
if (!isset($authsource)) {
// If authsource is not defined, init admin login.
SimpleSAML\Utils\Auth::requireAdmin();
}
/* We are using an authsource for login. */
$as = new SimpleSAML_Auth_Simple($authsource);
$as->requireAuth();
// User logged in with auth source.
SimpleSAML_Logger::debug('Statistics auth - valid login with auth source [' . $authsource . ']');
// Retrieving attributes
$attributes = $as->getAttributes();
if (!empty($allowedusers)) {
// Check if userid exists
if (!isset($attributes[$useridattr][0])) {
throw new Exception('User ID is missing');
}
// Check if userid is allowed access..
if (in_array($attributes[$useridattr][0], $allowedusers)) {
SimpleSAML_Logger::debug('Statistics auth - User granted access by user ID [' . $attributes[$useridattr][0] . ']');
return;
}
SimpleSAML_Logger::debug('Statistics auth - User denied access by user ID [' . $attributes[$useridattr][0] . ']');
} else {
SimpleSAML_Logger::debug('Statistics auth - no allowedUsers list.');
}
if (!is_null($acl)) {
$acl = new sspmod_core_ACL($acl);
if ($acl->allows($attributes)) {
SimpleSAML_Logger::debug('Statistics auth - allowed access by ACL.');
return;
}
SimpleSAML_Logger::debug('Statistics auth - denied access by ACL.');
} else {
SimpleSAML_Logger::debug('Statistics auth - no ACL configured.');
}
throw new SimpleSAML_Error_Exception('Access denied to the current user.');
}
示例7: persistNewAccessToken
/**
* @inheritDoc
*/
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
{
$as = $this->config->getString('auth');
$auth = new \SimpleSAML_Auth_Simple($as);
// We should be authenticated so this returns the session user attributes (or [] if not)
$attributes = $auth->getAttributes();
$scopes = [];
foreach ($accessTokenEntity->getScopes() as $scope) {
$scopes[] = $scope->getIdentifier();
}
$this->conn->insert($this->getTableName(), ['id' => $accessTokenEntity->getIdentifier(), 'scopes' => $scopes, 'attributes' => $attributes, 'expires_at' => $accessTokenEntity->getExpiryDateTime(), 'user_id' => $accessTokenEntity->getUserIdentifier(), 'client_id' => $accessTokenEntity->getClient()->getIdentifier()], ['string', 'json_array', 'json_array', 'datetime', 'string', 'string']);
}
示例8: downloadAction
public function downloadAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$filename = APPLICATION_ROOT . '/public_html/files/' . $this->_getParam('filename');
$filename = realpath($filename);
try {
$file = new SxCms_File($filename);
$data = $file->getCleanFile();
$identity = Zend_Auth::getInstance()->getIdentity();
if (!$file->isAllowed($identity)) {
$this->_helper->redirector->setExit(true)->gotoSimple('unauthorized', 'index');
return;
}
if ($file->isApb()) {
$as = new SimpleSAML_Auth_Simple('klavsts');
$attributes = $as->getAttributes();
if (!$attributes) {
$this->_forward('unauthorized', 'index', null, array('url' => $this->view->url()));
return;
}
$attributes = $attributes['urn:klav:docmanager'];
$filecheck = new SxCms_Filesystem($file->getPath());
$filecheck->setApb($attributes);
if (!$filecheck->isAllowed()) {
$this->_helper->redirector->setExit(true)->gotoSimple('unauthorized', 'index');
return;
}
}
// workaround for when PECL class finfo is not installed
$mimeType = 'application/octet-stream';
if (@class_exists('finfo')) {
$finfo = new finfo(FILEINFO_MIME);
$mimeType = $finfo->file($filename);
}
// mimetype "unknown", let's figure it out by filename extension
if ($mimeType == 'application/octet-stream') {
$ext = strtolower(end(explode('.', $filename)));
$types = simplexml_load_file(APPLICATION_PATH . '/var/mime-types.xml');
$result = $types->xpath('//mime-types/mime-type/ext[. ="' . $ext . '"]/..');
$result = $result[0]->attributes();
$result = (string) $result['name'];
$mimeType = $result;
}
$size = mb_strlen($data);
$this->getResponse()->setHeader('Content-Type', $mimeType)->setHeader('Content-Length', $size);
echo $data;
} catch (Exception $e) {
throw new Zend_Controller_Action_Exception('File not found', 404);
}
}
示例9: procesarFormulario
function procesarFormulario()
{
$saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
require_once $saml_lib_path;
// $aplication_base_url = 'http://10.20.0.38/splocal/';
$aplication_base_url = $this->host . $this->site . '/';
$source = 'SPcrono';
// Fuente de autenticación definida en el authsources del SP
$as = new SimpleSAML_Auth_Simple($source);
// Se pasa como parametro la fuente de autenticación
$login_params = array('ReturnTo' => $aplication_base_url . 'index.php');
$as->requireAuth($login_params);
$aaa = $as->getAttributes();
return false;
}
示例10: crearSesion
/**
* @METHOD crear_sesion
*
* Crea una nueva sesión en la base de datos.
* @PARAM usuario_aplicativo
* @PARAM nivel_acceso
* @PARAM expiracion
* @PARAM conexion_id
*
* @return boolean
* @access public
*/
function crearSesion()
{
$saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
require_once $saml_lib_path;
// $aplication_base_url = 'http://10.20.0.38/splocal/';
$aplication_base_url = $this->hostSSO . $this->site . '/';
$source = $this->SPSSO;
// Fuente de autenticación definida en el authsources del SP
$as = new SimpleSAML_Auth_Simple($source);
// Se pasa como parametro la fuente de autenticación
$login_params = array('ReturnTo' => $aplication_base_url . 'index.php');
$as->requireAuth($login_params);
$atributos = $as->getAttributes();
$this->sesionUsuario->crearSesion($atributos['usuario'][0]);
return $atributos;
}
示例11: authenticate
public function authenticate()
{
try {
$as = new \SimpleSAML_Auth_Simple($this->_domain);
$globalConfig = \SimpleSAML_Configuration::getInstance();
//$globalConfig::setConfigDir(G_CONFIGDIR.'saml/');
$as->requireAuth();
if ($as->isAuthenticated()) {
$attributes = $as->getAttributes();
if (!array_key_exists($this->_sso_settings['saml_email'], $attributes)) {
// TemplateController::setMessage(("A valid email is needed for account related communication").". ".("Check that the %s attribute (%s) defined in your configuration is correct",("Email"),$this->_sso_settings['saml_email']), 'error');
$this->ssoLogout();
} elseif (!array_key_exists($this->_sso_settings['saml_first_name'], $attributes)) {
// TemplateController::setMessage(("'%s' is required",("First name")).". ".("Check that the %s attribute (%s) defined in your configuration is correct",("First name"),$this->_sso_settings['saml_first_name']), 'error');
$this->ssoLogout();
} elseif (!array_key_exists($this->_sso_settings['saml_last_name'], $attributes)) {
// TemplateController::setMessage(("'%s' is required",("Last name")).". ".("Check that the %s attribute (%s) defined in your configuration is correct",("Last name"),$this->_sso_settings['saml_last_name']), 'error');
$this->ssoLogout();
} else {
if (trim($attributes[$this->_sso_settings['saml_email']][0]) == '') {
$attributes[$this->_sso_settings['saml_email']][0] = " ";
// TemplateController::setMessage(("A valid email is needed for account related communication"), 'error');
}
if (trim($attributes[$this->_sso_settings['saml_first_name']][0]) == '' && trim($attributes[$this->_sso_settings['saml_last_name']][0]) == '') {
$attributes[$this->_sso_settings['saml_first_name']][0] = ' ';
$attributes[$this->_sso_settings['saml_last_name']][0] = ' ';
} else {
if (trim($attributes[$this->_sso_settings['saml_first_name']][0]) == '') {
$attributes[$this->_sso_settings['saml_first_name']][0] = $attributes[$this->_sso_settings['saml_last_name']][0];
}
if (trim($attributes[$this->_sso_settings['saml_last_name']][0]) == '') {
$attributes[$this->_sso_settings['saml_last_name']][0] = $attributes[$this->_sso_settings['saml_first_name']][0];
}
}
$this->_login($attributes);
//pr($attributes);exit;
//echo "redirect now";exit;
//\SimpleSAML_Utilities::postRedirect("https://index.php", $attributes);
}
}
} catch (\SimpleSAML_Error_Error $e) {
$this->_samlErrorHandler($e);
} catch (\Exception $e) {
handleNormalFlowExceptions($e);
}
return $this;
}
示例12: beforeProcess
public function beforeProcess(&$action)
{
if (CopixConfig::get('conf_Saml_actif') != 1) {
return;
}
require_once COPIX_UTILS_PATH . '../../simplesamlphp/lib/_autoload.php';
$asId = 'iconito-sql';
if (CopixConfig::exists('default|conf_Saml_authSource') && CopixConfig::get('default|conf_Saml_authSource')) {
$asId = CopixConfig::get('default|conf_Saml_authSource');
}
$as = new SimpleSAML_Auth_Simple($asId);
$ppo->user = _currentUser();
if ($as->isAuthenticated() && !$ppo->user->isConnected()) {
$attributes = $as->getAttributes();
$uidAttribute = 'login_dbuser';
if (CopixConfig::exists('default|conf_Saml_uidAttribute') && CopixConfig::get('default|conf_Saml_uidAttribute')) {
$uidAttribute = CopixConfig::get('default|conf_Saml_uidAttribute');
}
$ppo->saml_user = null;
if (isset($attributes[$uidAttribute]) && isset($attributes[$uidAttribute][0])) {
$ppo->saml_user = $attributes[$uidAttribute][0];
}
if ($ppo->saml_user) {
$ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->saml_user);
if ($ppo->iconito_user['login']) {
_currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
$url_return = CopixUrl::get('kernel||doSelectHome');
// $url_return = CopixUrl::get ('assistance||users');
return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
} else {
$ppo->cas_error = 'no-iconito-user';
return _arPpo($ppo, 'cas.tpl');
}
}
}
if (!$as->isAuthenticated() && $ppo->user->isConnected()) {
$ppo->user = _currentUser();
if ($ppo->user->isConnected()) {
CopixAuth::getCurrentUser()->logout(array());
CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin()));
CopixAuth::destroyCurrentUser();
CopixSession::destroyNamespace('default');
}
}
}
示例13: __construct
public function __construct()
{
// Obligatoire
parent::__construct();
$this->data = array();
// System FED Oxylane
if (FEDACTIVE) {
require __DIR__ . '/../simplesaml/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('Oxylane-sp');
$isAuth = $as->isAuthenticated();
$url = $as->getLoginURL();
if (!$isAuth) {
//$url = $as->getLoginURL();
//echo '<p>You are not authenticated. <a href="' . htmlspecialchars($url) . '">Log in</a>.</p>';
$as->requireAuth();
} else {
//$url = $as->getLogoutURL();
//echo '<p>You are currently authenticated. <a href="' . htmlspecialchars($url) . '">Log out</a>.</p>';
$attributes = $as->getAttributes();
$uid = $attributes['uid'][0];
$this->data['fed']['0'] = $uid;
$this->data['fed']['1'] = $attributes['cn'][0];
$this->data['fed']['2'] = $attributes['mail'][0];
$this->load->model('admins_model', 'am');
$admins = $this->am->getAll();
if (!$this->in_array_column($uid, $admins)) {
echo "Utilisateur non autorisés";
redirect('welcome', 'refresh');
}
}
} else {
$this->data['fed']['0'] = "ID";
$this->data['fed']['1'] = "NOM";
$this->data['fed']['2'] = "MAIL";
}
// END System FED Oxylane
// Chargement des ressources pour tout le contrôleur
$this->load->database();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('pages_model', 'pm');
$this->load->model('chaines_model', 'cm');
$this->load->model('groupes_model', 'gm');
$this->load->model('logs_model', 'lm');
}
示例14: getUser
function getUser(SimpleSAML_Auth_Simple $as, ConfigProxy $janus_config)
{
// Get data from config
/** @var string $useridattr */
$useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName');
// Validate user
$attributes = $as->getAttributes();
// Check if userid exists
if (!isset($attributes[$useridattr])) {
echo json_encode(array('status' => 'user_id_is_missing'));
exit;
}
$userid = $attributes[$useridattr][0];
$user = new sspmod_janus_User();
$user->setUserid($userid);
$user->load(sspmod_janus_User::USERID_LOAD);
return $user;
}
示例15: getUserId
/**
* Retrieve the current user ID.
*
* @return string The current user ID, or NULL if the user isn't authenticated.
*/
public function getUserId()
{
if (!$this->authSource->isAuthenticated()) {
return NULL;
}
$attributes = $this->authSource->getAttributes();
if (!array_key_exists($this->usernameAttribute, $attributes)) {
throw new SimpleSAML_Error_Exception('Missing username attribute ' . var_export($this->usernameAttribute, TRUE) . ' in the attributes of the user.');
}
$values = array_values($attributes[$this->usernameAttribute]);
if (empty($values)) {
throw new SimpleSAML_Error_Exception('Username attribute was empty.');
}
if (count($values) > 1) {
throw new SimpleSAML_Error_Exception('More than one attribute value in username.');
}
$userId = $values[0];
return $userId;
}