Closed integrator-sev closed 1 year ago
The role mapping is only effected while the first log-in, if the user is already exists in Sentry, it won't update the roles.
Have you tried to create a new user?
Another note: The admin role is not superuser, it only means that you have admin permissions of the default organization. And the role mapping will do nothing if the default organization is not set or not found.
Yes, the first log-in success and user is 'admin'. So the AUTH_LDAP_ALWAYS_UPDATE_USER parameter doesn't make sense? it's a pity, because the user can first be a regular member, and later become a manager. And in this situation it would be very inconvenient to lose all his data or distract someone who does not deal with rights. Especially in the presence of ldap. Maybe you can somehow implement a re-mapping of roles when changing the user group in ldap?
This project was not originally designed by me. I only forked the original inactive project and make it compatible with the latest Sentry.
By the original design, AUTH_LDAP_ALWAYS_UPDATE_USER
will only update the user attributes such as name and email.
I think you may be right, the roles should be synced from LDAP.
The key code is that: https://github.com/PMExtra/sentry-auth-ldap/blob/e972999eb1788f75833238bc6141d0c45998461c/sentry_auth_ldap/backend.py#L64-L65
But I'm not sure if removing it will cause other side effects.
You can try to remove the 2 lines locally, and feedback here.
Yes, you was right. I comment two strings, restart sentry, log in and ...
In logs :
"django.db.utils.IntegrityError: UniqueViolation('duplicate key value violates unique constraint "sentry_organizationmember_organizationid.....
"SQL: INSERT INTO "sentry_organizationmember"
Should be something like "UPDATE" I think )
You should update this part: https://github.com/PMExtra/sentry-auth-ldap/blob/e972999eb1788f75833238bc6141d0c45998461c/sentry_auth_ldap/backend.py#L87-L94
There is a method named update_or_create
: https://docs.djangoproject.com/en/4.2/ref/models/querysets/#update-or-create
Welcome to submit a pull request if your attempt is successful.
You should update this part:
There is a method named
update_or_create
: https://docs.djangoproject.com/en/4.2/ref/models/querysets/#update-or-create
get_db_prep_lookup not supported for Bit ((( Maybe there are some other ideas that will help me understand where to dig?
replace with
OrganizationMember.objects.update_or_create(
organization=organizations[0],
user=user,
defaults={
"role": member_role,
"has_global_access": has_global_access,
"flags": getattr(OrganizationMember.flags, 'sso:linked')
}
)
Ok))) It works!
AUTH_LDAP_SENTRY_GROUP_ROLE_MAPPING not working... sentry on-premise(docker) v22.12.0 sentry-auth-ldap latest Active Directory as ldap ldapsearch returns "cn" in base64 format and in logs I see "django_auth_ldap: cn=myadminuser,ou=myadminou,ou=myplace,ou=users,dc=test,dc=domain,dc=local is a member of cn=test-sentry-admins,ou=system services,dc=test,dc=domain,dc=local"
BUT myadminuser don't have "admin" role when log in sentry
my sentry.conf.py
I experimented with different group types but role not mapping Can somebody help me, please ?