Skip to content

Commit ccc840a

Browse files
committed
Merged in [19412] from rjsparks@nostrum.com:
Only show roles in active roups in the oidc roles claim. Fixes ietf-tools#3424. - Legacy-Id: 19442 Note: SVN reference [19412] has been migrated to Git commit 21f5a55
2 parents d28b08f + 21f5a55 commit ccc840a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

ietf/ietfauth/tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ def test_oidc_code_auth(self):
810810

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

884887
# Create another registration, with a different email
885888
MeetingRegistration.objects.create(

ietf/ietfauth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims):
247247
)
248248

249249
def scope_roles(self):
250-
roles = self.user.person.role_set.values_list('name__slug', 'group__acronym')
250+
roles = self.user.person.role_set.filter(group__state_id__in=('active','bof','proposed')).values_list('name__slug', 'group__acronym')
251251
info = {
252252
'roles': list(roles)
253253
}

0 commit comments

Comments
 (0)