Skip to content
Richard Möhn edited this page May 16, 2022 · 1 revision

If you try to log in from an IdP and you end up in a redirect loop, it probably means:

  1. Authentication is failing.
  2. Devise's default behaviour on authentication failure causes the browser to bounce back and forth between the IdP and your app.

Authentication failure is addressed on other pages in this wiki. The Devise behaviour can be changed with a custom failure app. See https://github.com/heartcombo/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated. The respond method of the failure app could be implemented like this:

  def respond
    if attempted_path == saml_user_session_path
      redirect_to whatever_saml_sso_failure_path
    else
      super
    end
  end

Credits: https://github.com/apokalipto/devise_saml_authenticatable/issues/82#issuecomment-597481950