diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 326f5af275574567634b84a4b96e09d8546c447c..7a7ca43f1d0f67b103192cffec6d71f3a7f77c32 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -121,19 +121,19 @@ class Settings < Settingslogic
     end
 
     def ldap_enabled?
-      ldap['enabled']
-    rescue
+      ldap && ldap['enabled']
+    rescue Settingslogic::MissingSetting
       false
     end
 
     def omniauth_enabled?
       omniauth && omniauth['enabled']
-    rescue
+    rescue Settingslogic::MissingSetting
       false
     end
 
     def omniauth_providers
-      omniauth['providers'] || []
+      (omniauth_enabled? && omniauth['providers']) || []
     end
 
     def disable_gravatar?
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index ef058ff5ed132af0df85a1baafe8cbe974713cd0..90bd5d740811ea01851949d39f39a24e5767e680 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -17,7 +17,7 @@ module Gitlab
       end
     end
 
-    def create_from_omniauth auth, ldap = false
+    def create_from_omniauth(auth, ldap = false)
       provider = auth.provider
       uid = auth.info.uid || auth.uid
       name = auth.info.name.force_encoding("utf-8")
@@ -39,7 +39,7 @@ module Gitlab
         password_confirmation: password,
         projects_limit: Gitlab.config.default_projects_limit,
       )
-      if Gitlab.config.omniauth.block_auto_created_users && !ldap
+      if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
         @user.blocked = true
       end
       @user.save!
@@ -52,7 +52,7 @@ module Gitlab
       if @user = User.find_by_provider_and_extern_uid(provider, uid)
         @user
       else
-        if Gitlab.config.omniauth.allow_single_sign_on
+        if Gitlab.config.omniauth['allow_single_sign_on']
           @user = create_from_omniauth(auth)
           @user
         end
diff --git a/spec/lib/auth_spec.rb b/spec/lib/auth_spec.rb
index 5faf1307ed240fa0259c7f3eab662472fe39ecda..1e03bc591b485b6a5a08eef89025478bfd3f6cf4 100644
--- a/spec/lib/auth_spec.rb
+++ b/spec/lib/auth_spec.rb
@@ -4,6 +4,8 @@ describe Gitlab::Auth do
   let(:gl_auth) { Gitlab::Auth.new }
 
   before do
+    Gitlab.config.stub(omniauth: {})
+
     @info = mock(
       uid: '12djsak321',
       name: 'John',
@@ -64,7 +66,7 @@ describe Gitlab::Auth do
     end
 
     it "should create user if single_sing_on"do
-      Gitlab.config.omniauth.stub allow_single_sign_on: true
+      Gitlab.config.omniauth['allow_single_sign_on'] = true
       User.stub find_by_provider_and_extern_uid: nil
       gl_auth.should_receive :create_from_omniauth
       gl_auth.find_or_new_for_omniauth(@auth)