From 8c90c53463ae52ddce8de87fe5c6a9e2e79f1583 Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Fri, 26 Jun 2020 19:26:28 +0000
Subject: [PATCH] Added meeting registration 'affiliation' field to the OAuth2
 'registration' scope, so that Meetecho will have the information needed build
 bluesheets.  - Legacy-Id: 18070

---
 ietf/ietfauth/tests.py | 9 ++++++---
 ietf/ietfauth/utils.py | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ietf/ietfauth/tests.py b/ietf/ietfauth/tests.py
index ab8375f17..199d3609e 100644
--- a/ietf/ietfauth/tests.py
+++ b/ietf/ietfauth/tests.py
@@ -715,7 +715,7 @@ class OpenIDConnectTests(TestCase):
             # Get provider info
             client.provider_config( 'http://%s/api/openid' % host)
 
-            # No registration step -- we only supported this out-of-band
+            # No registration step -- we only support this out-of-band
 
             # Set shared client/provider information in the client
             client_reg = RegistrationResponse(  client_id= oid_client_record.client_id,
@@ -727,7 +727,9 @@ class OpenIDConnectTests(TestCase):
             RoleFactory(name_id='chair', person=person)
             meeting = MeetingFactory(type_id='ietf', date=datetime.date.today())
             MeetingRegistration.objects.create(
-                meeting=meeting, person=None, first_name=person.first_name(), last_name=person.last_name(), email=person.email())
+                    meeting=meeting, person=None, first_name=person.first_name(), last_name=person.last_name(),
+                    email=person.email(), ticket_type='full_week', reg_type='remote', affiliation='Some Company',
+                )
 
             # Get access authorisation
             session = {}
@@ -783,7 +785,8 @@ class OpenIDConnectTests(TestCase):
 
             # Get userinfo, check keys present
             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', ]:
                 self.assertIn(key, userinfo)
 
             r = client.do_end_session_request(state=params["state"], scope=args['scope'])
diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py
index 975e51b8c..aceff30f0 100644
--- a/ietf/ietfauth/utils.py
+++ b/ietf/ietfauth/utils.py
@@ -240,7 +240,7 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims):
     info_registration = (
             "IETF Meeting Registration Info",
             "Access to public IETF meeting registration information for the current meeting. "
-            "Includes meeting number, registration type and ticket type.",
+            "Includes meeting number, affiliation, registration type and ticket type.",
         )
 
     def scope_registration(self):
@@ -274,6 +274,7 @@ class OidcExtraScopeClaims(oidc_provider.lib.claims.ScopeClaims):
                 'ticket_type':  reg.ticket_type,
                 # in_person, onliine, hackathon:
                 'reg_type':     reg.reg_type,
+                'affiliation':  reg.affiliation,
             }
 
         return info