From 873b0db220b92008ed833f0909ecab8861bf00e8 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 18 Feb 2016 22:14:53 +0100 Subject: Revert "Merge branch 'saml-decoupling' into 'master' " This reverts commit c04e22fba8d130a58f498ff48127712d7dae17ee, reversing changes made to 0feab326d52222dc0ab5bd0a6b15dab297f44aa9. --- lib/gitlab/ldap/user.rb | 4 ---- lib/gitlab/o_auth/user.rb | 9 ++++----- lib/gitlab/saml/user.rb | 47 ----------------------------------------------- 3 files changed, 4 insertions(+), 56 deletions(-) delete mode 100644 lib/gitlab/saml/user.rb (limited to 'lib') diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index b84c81f1a6c..e044f0ecc6d 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -24,10 +24,6 @@ module Gitlab update_user_attributes end - def save - super('LDAP') - end - # instance methods def gl_user @gl_user ||= find_by_uid_and_provider || find_by_email || build_new_user diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 675ded92a89..d87a72f7ba3 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -26,7 +26,7 @@ module Gitlab gl_user.try(:valid?) end - def save(provider = 'OAuth') + def save unauthorized_to_create unless gl_user if needs_blocking? @@ -36,10 +36,10 @@ module Gitlab gl_user.save! end - log.info "(#{provider}) saving user #{auth_hash.email} from login with extern_uid => #{auth_hash.uid}" + log.info "(OAuth) saving user #{auth_hash.email} from login with extern_uid => #{auth_hash.uid}" gl_user rescue ActiveRecord::RecordInvalid => e - log.info "(#{provider}) Error saving user: #{gl_user.errors.full_messages}" + log.info "(OAuth) Error saving user: #{gl_user.errors.full_messages}" return self, e.record.errors end @@ -105,8 +105,7 @@ module Gitlab end def signup_enabled? - providers = Gitlab.config.omniauth.allow_single_sign_on - providers.include?(auth_hash.provider) + Gitlab.config.omniauth.allow_single_sign_on end def block_after_signup? diff --git a/lib/gitlab/saml/user.rb b/lib/gitlab/saml/user.rb deleted file mode 100644 index b1e30110ef5..00000000000 --- a/lib/gitlab/saml/user.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SAML extension for User model -# -# * Find GitLab user based on SAML uid and provider -# * Create new user from SAML data -# -module Gitlab - module Saml - class User < Gitlab::OAuth::User - - def save - super('SAML') - end - - def gl_user - @user ||= find_by_uid_and_provider - - if auto_link_ldap_user? - @user ||= find_or_create_ldap_user - end - - if auto_link_saml_enabled? - @user ||= find_by_email - end - - if signup_enabled? - @user ||= build_new_user - end - - @user - end - - def find_by_email - if auth_hash.has_email? - user = ::User.find_by(email: auth_hash.email.downcase) - user.identities.new(extern_uid: auth_hash.uid, provider: auth_hash.provider) if user - user - end - end - - protected - - def auto_link_saml_enabled? - Gitlab.config.omniauth.auto_link_saml_user - end - end - end -end -- cgit v1.2.1