Reputation: 203
I'm building a rails application and have successfully implemented Okta single sign on using the 'devise' gem and 'devise_saml_authenticable' gem. Everything is working great and I am able to successfully log into the app using my Okta account.
The one issue that I am facing is that if a user logs in that has an Okta account, but no account within the application, Otka goes into an endless redirect loop. How would I go about redirecting the user to a login error message or page instead?
Upvotes: 1
Views: 2514
Reputation: 203
Actually, I found out the reason for the issue. It was because, by default, Devise will redirect you back to the login page (http://localhost:3000/users/sign_in) if the user was unable to successfully authenticate (i.e., 401 error). If the user is signed into Okta, when they get redirected to the sign_in path then it tries to do the Okta authentication again, resulting in an endless loop.
To fix this I had to change Devise's default redirect, as instructed by this wiki: https://github.com/plataformatec/devise/wiki/How-To%3a-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated
Upvotes: 4