Class: OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Includes:
AuthHelper, AuthenticatesWithTwoFactorForAdminMode, Devise::Controllers::Rememberable, InitializesCurrentUserMode, KnownSignIn
Defined in:
app/controllers/omniauth_callbacks_controller.rb

Direct Known Subclasses

Ldap::OmniauthCallbacksController

Constant Summary

Constants included from KnownSignIn

KnownSignIn::KNOWN_SIGN_IN_COOKIE, KnownSignIn::KNOWN_SIGN_IN_COOKIE_EXPIRY

Constants included from CookiesHelper

CookiesHelper::COOKIE_TYPE_ENCRYPTED, CookiesHelper::COOKIE_TYPE_PERMANENT

Constants included from AuthHelper

AuthHelper::LDAP_PROVIDER, AuthHelper::PROVIDERS_WITH_ICONS

Instance Method Summary collapse

Methods included from CookiesHelper

#set_secure_cookie

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from InitializesCurrentUserMode

#current_user_mode

Methods included from AuthHelper

#allow_admin_mode_password_authentication_for_web?, #any_form_based_providers_enabled?, #auth_active?, #auth_providers, #button_based_providers, #button_based_providers_enabled?, #crowd_enabled?, #display_providers_on_profile?, #enabled_button_based_providers, #form_based_auth_provider_has_active_class?, #form_based_provider?, #form_based_provider_priority, #form_based_provider_with_highest_priority, #form_based_providers, #form_enabled_for_sign_in?, #google_tag_manager_enabled?, #icon_for_provider, #label_for_provider, #ldap_enabled?, #ldap_sign_in_enabled?, #link_provider_allowed?, #omniauth_enabled?, #provider_has_builtin_icon?, #provider_has_custom_icon?, #provider_has_icon?, #provider_image_tag, #providers_for_base_controller, #qa_class_for_provider, #unlink_provider_allowed?

Methods included from AuthenticatesWithTwoFactorForAdminMode

#admin_mode_authenticate_with_two_factor, #admin_mode_authenticate_with_two_factor_via_otp, #admin_mode_authenticate_with_two_factor_via_u2f, #admin_mode_authenticate_with_two_factor_via_webauthn, #admin_mode_prompt_for_two_factor

Instance Method Details

#atlassian_oauth2Object


87
88
89
# File 'app/controllers/omniauth_callbacks_controller.rb', line 87

def atlassian_oauth2
  omniauth_flow(Gitlab::Auth::Atlassian)
end

#auth0Object


71
72
73
74
75
76
77
# File 'app/controllers/omniauth_callbacks_controller.rb', line 71

def auth0
  if oauth['uid'].blank?
    
  else
    handle_omniauth
  end
end

#authentiqObject


63
64
65
66
67
68
69
# File 'app/controllers/omniauth_callbacks_controller.rb', line 63

def authentiq
  if params['sid']
    handle_service_ticket oauth['provider'], params['sid']
  end

  handle_omniauth
end

#cas3Object


54
55
56
57
58
59
60
61
# File 'app/controllers/omniauth_callbacks_controller.rb', line 54

def cas3
  ticket = params['ticket']
  if ticket
    handle_service_ticket oauth['provider'], ticket
  end

  handle_omniauth
end

#failureObject

Extend the standard implementation to also increment the number of failed sign in attempts


26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/omniauth_callbacks_controller.rb', line 26

def failure
  if params[:username].present? && AuthHelper.form_based_provider?(failed_strategy.name)
    user = User.(params[:username])

    user&.increment_failed_attempts!
    (params[:username], failed_strategy.name)
  end

  super
end

#failure_messageObject

Extend the standard message generation to accept our custom exception


38
39
40
41
42
43
44
45
46
# File 'app/controllers/omniauth_callbacks_controller.rb', line 38

def failure_message
  exception = request.env["omniauth.error"]
  error = exception.error_reason if exception.respond_to?(:error_reason)
  error ||= exception.error        if exception.respond_to?(:error)
  error ||= exception.message      if exception.respond_to?(:message)
  error ||= request.env["omniauth.error.type"].to_s

  error.to_s.humanize if error
end

#handle_omniauthObject


16
17
18
# File 'app/controllers/omniauth_callbacks_controller.rb', line 16

def handle_omniauth
  omniauth_flow(Gitlab::Auth::OAuth)
end

#salesforceObject


79
80
81
82
83
84
85
# File 'app/controllers/omniauth_callbacks_controller.rb', line 79

def salesforce
  if oauth.dig('extra', 'email_verified')
    handle_omniauth
  else
    
  end
end

#samlObject


48
49
50
51
52
# File 'app/controllers/omniauth_callbacks_controller.rb', line 48

def saml
  omniauth_flow(Gitlab::Auth::Saml)
rescue Gitlab::Auth::Saml::IdentityLinker::UnverifiedRequest
  redirect_unverified_saml_initiation
end