Provide a dots oidc claim for online badges. Commit ready for merge.

- Legacy-Id: 19437
This commit is contained in:
Robert Sparks 2021-10-18 21:39:00 +00:00
parent cd748cd760
commit 6351ce86c2
3 changed files with 27 additions and 2 deletions

View file

@ -827,7 +827,7 @@ class OpenIDConnectTests(TestCase):
session["nonce"] = rndstr() session["nonce"] = rndstr()
args = { args = {
"response_type": "code", "response_type": "code",
"scope": ['openid', 'profile', 'email', 'roles', 'registration', ], "scope": ['openid', 'profile', 'email', 'roles', 'registration', 'dots' ],
"nonce": session["nonce"], "nonce": session["nonce"],
"redirect_uri": redirect_uris[0], "redirect_uri": redirect_uris[0],
"state": session["state"] "state": session["state"]
@ -876,7 +876,7 @@ class OpenIDConnectTests(TestCase):
# Get userinfo, check keys present # Get userinfo, check keys present
userinfo = client.do_user_info_request(state=params["state"], scope=args['scope']) userinfo = client.do_user_info_request(state=params["state"], scope=args['scope'])
for key in [ 'email', 'family_name', 'given_name', 'meeting', 'name', 'roles', for key in [ 'email', 'family_name', 'given_name', 'meeting', 'name', 'roles',
'ticket_type', 'reg_type', 'affiliation', 'picture', ]: 'ticket_type', 'reg_type', 'affiliation', 'picture', 'dots', ]:
self.assertIn(key, userinfo) self.assertIn(key, userinfo)
self.assertTrue(userinfo[key]) self.assertTrue(userinfo[key])
self.assertIn('remote', set(userinfo['reg_type'].split())) self.assertIn('remote', set(userinfo['reg_type'].split()))

View file

@ -25,6 +25,7 @@ import debug # pyflakes:ignore
from ietf.group.models import Role, GroupFeatures from ietf.group.models import Role, GroupFeatures
from ietf.person.models import Person from ietf.person.models import Person
from ietf.person.utils import get_dots
from ietf.doc.utils_bofreq import bofreq_editors from ietf.doc.utils_bofreq import bofreq_editors
def user_is_person(user, person): def user_is_person(user, person):
@ -253,6 +254,10 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims):
} }
return info return info
def scope_dots(self):
dots = get_dots(self.user.person)
return { 'dots': dots }
info_registration = ( info_registration = (
"IETF Meeting Registration Info", "IETF Meeting Registration Info",
"Access to public IETF meeting registration information for the current meeting. " "Access to public IETF meeting registration information for the current meeting. "

View file

@ -15,6 +15,7 @@ from django.core.exceptions import ObjectDoesNotExist
import debug # pyflakes:ignore import debug # pyflakes:ignore
from ietf.person.models import Person from ietf.person.models import Person
from ietf.group.models import GroupFeatures
from ietf.utils.mail import send_mail from ietf.utils.mail import send_mail
def merge_persons(request, source, target, file=sys.stdout, verbose=False): def merge_persons(request, source, target, file=sys.stdout, verbose=False):
@ -220,3 +221,22 @@ def get_active_irsg():
cache.set(cache_key, active_irsg_balloters) cache.set(cache_key, active_irsg_balloters)
return active_irsg_balloters return active_irsg_balloters
def get_dots(person):
roles = person.role_set.filter(group__state_id__in=('active','bof','proposed'))
chair_group_types = ['wg', 'program', 'rg', 'iabasg']
dots = []
if roles.filter(name_id='chair',group__type_id__in=chair_group_types).exists():
dots.append('chair')
if roles.filter(group__acronym='iesg',name_id='ad').exists():
dots.append('ad')
if roles.filter(group__acronym='iab',name_id='member').exists():
dots.append('iab')
if roles.filter(group__acronym='irsg').exists():
dots.append('irsg')
if roles.filter(group__acronym='llc-board').exists():
dots.append('llc')
if roles.filter(group__acronym='ietf-trust').exists():
dots.append('trust')
if roles.filter(group__acronym__startswith='nomcom', name_id__in=('chair','member')).exists():
dots.append('nomcom')
return dots