Skip to content

Commit

Permalink
Allow nested groups claim
Browse files Browse the repository at this point in the history
  • Loading branch information
zorn-v committed Sep 13, 2019
1 parent 6ad19d9 commit f7cf752
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ or
{"roles": "admin,user"}
```

Also nested claims is supported. For example `resource_access.client-id.roles` for

```json
"resource_access": {
"client-id": {
"roles": [
"client-role-1",
"client-role-2"
]
}
}
```


You can use provider groups in two ways:

1. Map provider groups to existing nextcloud groups
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>Social Login</name>
<summary>Social login via OAuth or OpenID</summary>
<description> </description>
<version>2.0.3</version>
<version>2.1.0</version>
<licence>agpl</licence>
<author>zorn-v</author>
<namespace>SocialLogin</namespace>
Expand Down
12 changes: 11 additions & 1 deletion lib/Provider/CustomOAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ public function getUserProfile()
protected function getGroups(Data\Collection $data)
{
if ($groupsClaim = $this->config->get('groups_claim')) {
$groups = $data->get($groupsClaim);
$nestedClaims = explode('.', $groupsClaim);
$claim = array_shift($nestedClaims);
$groups = $data->get($claim);
while (count($nestedClaims) > 0) {
$claim = array_shift($nestedClaims);
if (!isset($groups[$claim])) {
$groups = [];
break;
}
$groups = $groups[$claim];
}
if (is_array($groups)) {
return $groups;
} elseif (is_string($groups)) {
Expand Down

0 comments on commit f7cf752

Please sign in to comment.