Skip to content

Commit

Permalink
Only show roles in active roups in the oidc roles claim. Fixes #3424.…
Browse files Browse the repository at this point in the history
… Commit ready for merge.

 - Legacy-Id: 19412
  • Loading branch information
rjsparks committed Oct 11, 2021
1 parent d1a9f0d commit 21f5a55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ietf/ietfauth/tests.py
Expand Up @@ -810,7 +810,8 @@ def test_oidc_code_auth(self):

# Get a user for which we want to get access
person = PersonFactory(with_bio=True)
RoleFactory(name_id='chair', person=person)
active_group = RoleFactory(name_id='chair', person=person).group
closed_group = RoleFactory(name_id='chair', person=person, group__state_id='conclude').group
# an additional email
EmailFactory(person=person)
email_list = person.email_set.all().values_list('address', flat=True)
Expand Down Expand Up @@ -880,6 +881,8 @@ def test_oidc_code_auth(self):
self.assertTrue(userinfo[key])
self.assertIn('remote', set(userinfo['reg_type'].split()))
self.assertNotIn('hackathon', set(userinfo['reg_type'].split()))
self.assertIn(active_group.acronym, [i[1] for i in userinfo['roles']])
self.assertNotIn(closed_group.acronym, [i[1] for i in userinfo['roles']])

# Create another registration, with a different email
MeetingRegistration.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion ietf/ietfauth/utils.py
Expand Up @@ -247,7 +247,7 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims):
)

def scope_roles(self):
roles = self.user.person.role_set.values_list('name__slug', 'group__acronym')
roles = self.user.person.role_set.filter(group__state_id__in=('active','bof','proposed')).values_list('name__slug', 'group__acronym')
info = {
'roles': list(roles)
}
Expand Down

0 comments on commit 21f5a55

Please sign in to comment.