diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-31 09:01:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-31 09:01:53 +0000 |
commit | a47a6d6fd56f92497b164d45ff9b53023202c4b1 (patch) | |
tree | fdbfbee5e51865b3a43749dbbdf0d03047001ed7 /app/models | |
parent | 616d6dc767ba33148a11768f3d73504368897ee9 (diff) | |
download | gitlab-ce-a47a6d6fd56f92497b164d45ff9b53023202c4b1.tar.gz |
Add latest changes from gitlab-org/gitlab@15-10-stable-ee
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user_synced_attributes_metadata.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/app/models/user_synced_attributes_metadata.rb b/app/models/user_synced_attributes_metadata.rb index 4cd0e3fb828..6b23bce6406 100644 --- a/app/models/user_synced_attributes_metadata.rb +++ b/app/models/user_synced_attributes_metadata.rb @@ -14,7 +14,7 @@ class UserSyncedAttributesMetadata < ApplicationRecord def read_only_attributes return [] unless sync_profile_from_provider? - self.class.syncable_attributes.select { |key| synced?(key) } + SYNCABLE_ATTRIBUTES.select { |key| synced?(key) } end def synced?(attribute) @@ -26,12 +26,11 @@ class UserSyncedAttributesMetadata < ApplicationRecord end class << self - def syncable_attributes - if Gitlab.config.ldap.enabled && !Gitlab.config.ldap.sync_name - SYNCABLE_ATTRIBUTES - %i[name] - else - SYNCABLE_ATTRIBUTES - end + def syncable_attributes(provider = nil) + return SYNCABLE_ATTRIBUTES unless provider && ldap_provider?(provider) + return SYNCABLE_ATTRIBUTES if ldap_sync_name?(provider) + + SYNCABLE_ATTRIBUTES - %i[name] end end @@ -40,4 +39,17 @@ class UserSyncedAttributesMetadata < ApplicationRecord def sync_profile_from_provider? Gitlab::Auth::OAuth::Provider.sync_profile_from_provider?(provider) end + + class << self + def ldap_provider?(provider) + Gitlab::Auth::OAuth::Provider.ldap_provider?(provider) + end + + def ldap_sync_name?(provider) + return false unless provider + + config = Gitlab::Auth::Ldap::Config.new(provider) + config.enabled? && config.sync_name + end + end end |