From 0f2216b8b90097cfd6075859dda3db63e25f2025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 20 Apr 2023 19:48:07 +0300 Subject: [PATCH 1/2] Add stripdomain config option --- conf/default.php | 1 + conf/metadata.php | 1 + lang/en/settings.php | 1 + 3 files changed, 3 insertions(+) diff --git a/conf/default.php b/conf/default.php index f3fa463..5e0552f 100644 --- a/conf/default.php +++ b/conf/default.php @@ -8,3 +8,4 @@ $conf['secret'] = ''; $conf['tenant'] = ''; $conf['fetchgroups'] = 0; +$conf['stripdomain'] = 0; diff --git a/conf/metadata.php b/conf/metadata.php index fbacb20..8a93082 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -8,3 +8,4 @@ $meta['secret'] = array('password'); $meta['tenant'] = array('string'); $meta['fetchgroups'] = array('onoff'); +$meta['stripdomain'] = array('onoff'); diff --git a/lang/en/settings.php b/lang/en/settings.php index 5abf9a9..780dd58 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -8,3 +8,4 @@ $lang['secret'] = 'Cient Secret'; $lang['openidurl'] = 'Your tenant name or ID'; $lang['fetchgroups'] = 'By default only roles from the JWT are used as user groups. Enabling this option fetches group data.'; +$lang['stripdomain'] = 'Strip @domain from preferred_username'; From 33c016315105ff2773d1f96a936e8d00145c61ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 20 Apr 2023 19:49:16 +0300 Subject: [PATCH 2/2] Strip domain if stripdomain config is enabled --- action.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.php b/action.php index 1271827..0d99d97 100644 --- a/action.php +++ b/action.php @@ -45,6 +45,10 @@ public function getUser() $data['mail'] = $result['email']; $data['grps'] = array_merge($result['groups'] ?? [], $result['roles'] ?? []); + if ($this->getConf('stripdomain')) { + $data['user'] = explode('@', $data['user'], 2)[0]; + } + if ($this->getConf('fetchgroups')) { $usergroups = $oauth->request(Azure::GRAPH_MEMBEROF); $usergroups = json_decode($usergroups, true);