mirror of
https://github.com/inventree/InvenTree.git
synced 2026-01-28 09:03:41 +00:00
fix(auth): Use correct data for SSO group sync (#11164)
https://docs.allauth.org/en/latest/release-notes/recent.html#id18 Since django-allauth 65.11.0 (InvenTree v1.1.X), the extra_data is divided into separate userinfo and id_token objects
This commit is contained in:
@@ -96,7 +96,9 @@ def ensure_sso_groups(sender, sociallogin: SocialLogin, **kwargs):
|
||||
group_map = json.loads(get_global_setting('SSO_GROUP_MAP'))
|
||||
# map SSO groups to InvenTree groups
|
||||
group_names = []
|
||||
for sso_group in sociallogin.account.extra_data.get(group_key, []):
|
||||
for sso_group in sociallogin.account.extra_data.get('userinfo', {}).get(
|
||||
group_key, []
|
||||
):
|
||||
if mapped_name := group_map.get(sso_group):
|
||||
group_names.append(mapped_name)
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestSsoGroupSync(TransactionTestCase):
|
||||
'SSO_GROUP_MAP', '{"idp_group": "inventree_group"}'
|
||||
)
|
||||
# configure sociallogin
|
||||
extra_data = {'groups': ['idp_group']}
|
||||
extra_data = {'userinfo': {'groups': ['idp_group']}}
|
||||
self.group = Group(name='inventree_group')
|
||||
self.group.save()
|
||||
# ensure default group exists
|
||||
|
||||
Reference in New Issue
Block a user