Auth\Casuser: fix handling user attributes type & multivalued properties
This commit is contained in:
parent
f16bfb5278
commit
b2566f90e3
1 changed files with 10 additions and 2 deletions
|
@ -10,6 +10,7 @@ use EesyPHP\Check;
|
|||
use EesyPHP\Config;
|
||||
use EesyPHP\I18n;
|
||||
use EesyPHP\Log;
|
||||
use function EesyPHP\ensure_is_array;
|
||||
use function EesyPHP\format_callable;
|
||||
use function EesyPHP\vardump;
|
||||
|
||||
|
@ -33,12 +34,19 @@ class Casuser extends Backend {
|
|||
foreach(App::get('auth.cas.user_attributes') as $name => $attr_config) {
|
||||
$cas_name = Config::get("cas_name", null, 'string', false, $attr_config);
|
||||
$alt_cas_name = Config::get("alt_cas_name", $name, 'string', false, $attr_config);
|
||||
if (!$cas_name || is_null(Cas :: get_attr($cas_name)))
|
||||
$type = Config::get("type", "string", "string", false, $attr_config);
|
||||
if (!$cas_name || is_null(Cas :: get_attr($cas_name, null, $type)))
|
||||
$cas_name = $alt_cas_name;
|
||||
$info[$name] = Cas :: get_attr(
|
||||
$cas_name?$cas_name:$name,
|
||||
default: Config::get("default", null, null, false, $attr_config)
|
||||
Config::get("default", null, null, false, $attr_config),
|
||||
$type
|
||||
);
|
||||
$multivalued = Config::get("multivalued", false, "bool", false, $attr_config);
|
||||
if ($multivalued)
|
||||
$info[$name] = ensure_is_array($info[$name]);
|
||||
elseif (is_array($info[$name]))
|
||||
$info[$name] = $info[$name][0];
|
||||
}
|
||||
Log::debug('User "%s" info computed from CAS attributes:\n%s', $username, vardump($info));
|
||||
return new User($username, '\\EesyPHP\\Auth\\Casuser', $info);
|
||||
|
|
Loading…
Reference in a new issue