Created
October 8, 2019 11:10
-
-
Save ETiV/8ae6a5119e461bd2825a62d2bb1dec52 to your computer and use it in GitHub Desktop.
解决 GitLab 使用第三方 SSO OAuth 登录后,external user 不符合后台配置的问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- user.rb 2019-10-08 18:55:14.014163674 +0800 | |
+++ user-patched.rb 2019-10-08 19:04:01.748236038 +0800 | |
@@ -48,7 +48,7 @@ | |
gl_user.block if block_after_save | |
- log.info "(#{provider}) saving user #{auth_hash.email} from login with admin => #{gl_user.admin}, extern_uid => #{auth_hash.uid}" | |
+ log.info "(#{provider}) saving user #{auth_hash.email} from login with admin => #{gl_user.admin}, extern_uid => #{auth_hash.uid}, primary email => #{gl_user.email}, user.external => #{gl_user.external}" | |
gl_user | |
rescue ActiveRecord::RecordInvalid => e | |
log.info "(#{provider}) Error saving user #{auth_hash.uid} (#{auth_hash.email}): #{gl_user.errors.full_messages}" | |
@@ -67,7 +67,8 @@ | |
user ||= find_or_build_ldap_user if auto_link_ldap_user? | |
user ||= build_new_user if signup_enabled? | |
- user.external = true if external_provider? && user&.new_record? | |
+ settings = Gitlab::CurrentSettings.current_application_settings | |
+ user.external = settings.user_default_internal_regex_enabled? ? settings.user_default_internal_regex_instance.match(auth_hash.email).nil? : false | |
user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment