[4.0.0]Custom pipeline - Create groups for SAML #16000
-
Hi, In version 3.7, I had a custom pipeline creating groups for SAML users
This pipeline works in 3.7, and creates the user / the group if it doesn't exist, and puts the user in the group In can find these groups in the DB in the table auth_group
In Version 4.0 however, it seems auth_group is not used anymore, which might be expected from release notes.
My pipeline still manages to create the user, but it has now 2 issues
To explain, my pipeline associates user to groups with
But not with
Many changes in this version... is it related to Django version going from 4.2 to 5.0 ? Should I enable DJANGO_ADMIN_ENABLED in config file ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Same issue here (using Authentik for SSO) When trying to add groups via id using code below:
I get this error:
What is the correct way now to map groups via custom pipeline? |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for clarification. |
Beta Was this translation helpful? Give feedback.
@pgodzwa I found the solution reading docs 👍
As an introduction :
https://github.com/netbox-community/netbox/blob/develop/docs/development/models.md
We find the code here
https://github.com/netbox-community/netbox/blob/develop/netbox%2Fnetbox%2Fauthentication%2F__init__.py
I had to make 2 changes :
This line
from django.contrib.auth.models import Group
Is now
from netbox.authentication import Group
And in new Netbox group implementation, we can't assign users to a group, only groups to user (I'll submit a bug report just in case) so this line (in my original code)
group.user_set.add(user)
Is now
user.groups.add(group)