Skip to content

Commit 07c97dd

Browse files
InuSashafguillot
authored andcommitted
Add support for groups
1 parent 43551c6 commit 07c97dd

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Template/config/integration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<?= $this->form->text('oauth2_email_domains', $values) ?>
4141
<p class="form-help"><?= t('Use a comma to enter multiple domains: domain1.tld, domain2.tld') ?></p>
4242

43+
<?= $this->form->label(t('Groups Key'), 'oauth2_key_groups') ?>
44+
<?= $this->form->text('oauth2_key_groups', $values) ?>
45+
<p class="form-help"><?= t('Leave empty, when no group mapping is wanted') ?></p>
46+
4347
<div class="form-actions">
4448
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
4549
</div>

User/GenericOAuth2UserProvider.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,21 @@ public function getEmail()
157157
*/
158158
public function getExternalGroupIds()
159159
{
160-
return array();
160+
$groups = $this->getKey('oauth2_key_groups');
161+
162+
if (empty($groups)) {
163+
$this->logger->debug('OAuth2: '.$this->getUsername().' has no groups');
164+
return array();
165+
}
166+
167+
$groups = array_unique($groups);
168+
$this->logger->debug('OAuth2: '.$this->getUsername().' groups are '. join(',', $groups));
169+
170+
foreach ($groups as $group) {
171+
$this->groupModel->getOrCreateExternalGroupId($group, $group);
172+
}
173+
174+
return $groups;
161175
}
162176

163177
/**

0 commit comments

Comments
 (0)