Oidc: allow custom username property

Allow a custom field `username_property` in Config to not force `email`. The default stays `email`.
pull/9664/head
ftoppi 2024-04-05 13:36:28 +02:00 committed by GitHub
parent b8ef22754f
commit 4defa600a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -27,7 +27,8 @@ class Oidc
$claims = $oidc->getVerifiedClaims();
$mispUsername = $claims->email ?? $oidc->requestUserInfo('email');
$usernameProperty = $this->getConfig('username_property', 'email');
$mispUsername = $claims->$usernameProperty ?? $oidc->requestUserInfo($usernameProperty);
if (empty($mispUsername)) {
$sub = $claims->sub ?? 'UNKNOWN';
throw new Exception("OIDC user $sub doesn't have email address, that is required by MISP.");