Class: OmniauthCallbacksController
- Inherits:
-
Devise::OmniauthCallbacksController
- Object
- Devise::OmniauthCallbacksController
- OmniauthCallbacksController
- Includes:
- AcceptsPendingInvitations, ActionView::Helpers::TextHelper, AuthHelper, AuthenticatesWithTwoFactorForAdminMode, Devise::Controllers::Rememberable, InitializesCurrentUserMode, InternalRedirect, KnownSignIn, Onboarding::Redirectable, SafeFormatHelper, SynchronizeBroadcastMessageDismissals
- Defined in:
- app/controllers/omniauth_callbacks_controller.rb
Direct Known Subclasses
Constant Summary collapse
- ACTIVE_SINCE_KEY =
'active_since'- INVALID_FRAGMENT_EXP =
Following www.rfc-editor.org/rfc/rfc3986.txt to check for the present of reserved characters in redirect_fragment
%r{[;/?:@&=+$,]+}- InvalidFragmentError =
Class.new(StandardError)
- SignUpFromRestrictedCountyError =
To be used in ee version for raising error on user signup if user is from restricted country
Class.new(StandardError)
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::POPULAR_PROVIDERS, AuthHelper::PROVIDERS_WITH_ICONS, AuthHelper::SHA1_CHAR_PAIR_COUNT, AuthHelper::SHA256_CHAR_PAIR_COUNT
Instance Method Summary collapse
- #atlassian_oauth2 ⇒ Object
- #auth0 ⇒ Object
-
#failure ⇒ Object
Extend the standard implementation to also increment the number of failed sign in attempts.
-
#failure_message ⇒ Object
Extend the standard message generation to accept our custom exception.
- #handle_omniauth ⇒ Object
- #jwt ⇒ Object
-
#openid_connect ⇒ Object
overridden in EE.
- #salesforce ⇒ Object
- #saml ⇒ Object
Methods included from SynchronizeBroadcastMessageDismissals
#synchronize_broadcast_message_dismissals
Methods included from SafeFormatHelper
Methods included from InternalRedirect
#full_path_for_uri, #host_allowed?, #referer_path, #safe_redirect_path, #safe_redirect_path_for_url, #sanitize_redirect
Methods included from AcceptsPendingInvitations
#accept_pending_invitations, #after_pending_invitations_hook
Methods included from CookiesHelper
Methods included from InitializesCurrentUserMode
Methods included from AuthHelper
#allow_admin_mode_password_authentication_for_web?, #any_form_based_providers_enabled?, #auth_active?, #auth_app_owner_text, #auth_providers, #button_based_providers, #button_based_providers_enabled?, #certificate_fingerprint_algorithm, #codes_two_factor_authentication_data, #crowd_enabled?, #current_password_required?, #delete_otp_authenticator_data, #delete_passkey_data, #delete_webauthn_device_data, #disable_two_factor_authentication_data, #display_providers_on_profile?, #enabled_button_based_providers, #enabled_button_based_providers_for_signup, #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?, #icon_for_provider, #label_for_provider, #ldap_enabled?, #ldap_sign_in_enabled?, #link_provider_allowed?, #oidc_providers, #omniauth_enabled?, #popular_enabled_button_based_providers, #provider_has_builtin_icon?, #provider_has_custom_icon?, #provider_has_icon?, #provider_image_tag, #providers_for_base_controller, #saml_providers, #signup_button_based_providers_enabled?, #step_up_auth_documentation_link, #step_up_auth_params, #test_id_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_webauthn, #admin_mode_prompt_for_two_factor
Instance Method Details
#atlassian_oauth2 ⇒ Object
111 112 113 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 111 def atlassian_oauth2 omniauth_flow(Gitlab::Auth::Atlassian) end |
#auth0 ⇒ Object
95 96 97 98 99 100 101 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 95 def auth0 if oauth['uid'].blank? fail_auth0_login else handle_omniauth end end |
#failure ⇒ Object
Extend the standard implementation to also increment the number of failed sign in attempts
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 62 def failure update_login_counter_metric(failed_strategy.name, 'failed') log_saml_response if params['SAMLResponse'] username = params[:username].to_s if username.present? && AuthHelper.form_based_provider?(failed_strategy.name) user = User.find_by_login(username) user&.increment_failed_attempts! log_failed_login(username, failed_strategy.name) end super end |
#failure_message ⇒ Object
Extend the standard message generation to accept our custom exception
78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 78 def 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. if exception.respond_to?(:message) error ||= request.env["omniauth.error.type"].to_s error.to_s.humanize if error end |
#handle_omniauth ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 34 def handle_omniauth if ::AuthHelper.saml_providers.include?(oauth['provider'].to_sym) saml elsif ::AuthHelper.oidc_providers.include?(oauth['provider'].to_sym) openid_connect else omniauth_flow(Gitlab::Auth::OAuth) end end |
#jwt ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 53 def jwt omniauth_flow( Gitlab::Auth::OAuth, identity_linker: Gitlab::Auth::Jwt::IdentityLinker.new(current_user, oauth, session) ) end |
#openid_connect ⇒ Object
overridden in EE
49 50 51 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 49 def openid_connect omniauth_flow(Gitlab::Auth::OAuth) end |
#salesforce ⇒ Object
103 104 105 106 107 108 109 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 103 def salesforce if oauth.dig('extra', 'email_verified') handle_omniauth else fail_salesforce_login end end |
#saml ⇒ Object
88 89 90 91 92 93 |
# File 'app/controllers/omniauth_callbacks_controller.rb', line 88 def saml log_saml_response omniauth_flow(Gitlab::Auth::Saml) rescue Gitlab::Auth::Saml::IdentityLinker::UnverifiedRequest redirect_unverified_saml_initiation end |