Skip to content
Snippets Groups Projects
Commit 2602401b authored by Rafael dos Santos Silva's avatar Rafael dos Santos Silva
Browse files

Handle group sync

parent f4d5f139
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,31 @@ class SamlAuthenticator < ::Auth::OAuth2Authenticator ...@@ -63,6 +63,31 @@ class SamlAuthenticator < ::Auth::OAuth2Authenticator
result.username = '' result.username = ''
end end
if GlobalSetting.try(:saml_omit_username) && result.user.blank?
result.omit_username = true
end
# if groups sync is enabled
if GlobalSetting.try(:saml_sync_groups) && GlobalSetting.try(:saml_sync_groups_list) && auth.extra.present? && auth.extra[:raw_info].present? && !result.user.blank?
total_group_list = GlobalSetting.try(:saml_sync_groups_list).split('|')
user_group_list = auth.extra[:raw_info].attributes['memberOf']
groups_to_add = Group.where(name: user_group_list)
groups_to_add.each do |group|
group.add result.user
end
groups_to_remove = Group.where(name: total_group_list - user_group_list)
groups_to_remove.each do |group|
group.remove result.user
end
end
result.extra_data = { saml_user_id: uid } result.extra_data = { saml_user_id: uid }
result result
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment