Skip to content

Commit b050cd4

Browse files
committed
feat(oauth): extend groups scope to add sysadmin claim
1 parent 99123cf commit b050cd4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

intranet/apps/oauth/validators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import logging
2+
13
from oauth2_provider.oauth2_validators import OAuth2Validator
24

5+
logger = logging.getLogger(__name__)
6+
37

48
class IonOIDCValidator(OAuth2Validator):
59
oidc_claim_scope = OAuth2Validator.oidc_claim_scope.copy()
6-
oidc_claim_scope.update({"groups": "groups"}) # manually add it since groups is not part of the standard OIDC spec
10+
oidc_claim_scope.update({"groups": "groups", "is_sysadmin": "groups"}) # manually add it since groups is not part of the standard OIDC spec
711

812
def get_additional_claims(self, request):
913
claims = {}
@@ -31,6 +35,7 @@ def get_additional_claims(self, request):
3135
claims.update(
3236
{
3337
"groups": list(user.groups.values_list("name", flat=True)),
38+
"is_sysadmin": user.groups.filter(name="Sysadmin(R) -- Permissions").exists(),
3439
}
3540
)
3641

0 commit comments

Comments
 (0)