2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-03-11 22:54:17 +00:00

fix(auth): Use correct data for SSO group sync (#11164) (#11167)

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

(cherry picked from commit 2b091832d0)

Co-authored-by: Philipp Fruck <dev@p-fruck.de>
This commit is contained in:
github-actions[bot]
2026-01-20 07:50:47 +11:00
committed by GitHub
parent db7c133eff
commit 73c4f884c3
2 changed files with 4 additions and 2 deletions

View File

@@ -96,7 +96,9 @@ def ensure_sso_groups(sender, sociallogin: SocialLogin, **kwargs):
group_map = json.loads(get_global_setting('SSO_GROUP_MAP')) group_map = json.loads(get_global_setting('SSO_GROUP_MAP'))
# map SSO groups to InvenTree groups # map SSO groups to InvenTree groups
group_names = [] 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): if mapped_name := group_map.get(sso_group):
group_names.append(mapped_name) group_names.append(mapped_name)

View File

@@ -38,7 +38,7 @@ class TestSsoGroupSync(TransactionTestCase):
'SSO_GROUP_MAP', '{"idp_group": "inventree_group"}' 'SSO_GROUP_MAP', '{"idp_group": "inventree_group"}'
) )
# configure sociallogin # configure sociallogin
extra_data = {'groups': ['idp_group']} extra_data = {'userinfo': {'groups': ['idp_group']}}
self.group = Group(name='inventree_group') self.group = Group(name='inventree_group')
self.group.save() self.group.save()
# ensure default group exists # ensure default group exists