Open GMolini opened 3 years ago
So, the problem comes definitely after the redirect_to redirect_route
in the redirect_callbacks
method. If I dont use a redirect and call the omniauth_success
instead it works and I am able to log in successfully.
Hi,
Im trying to develop an addin for outlook. The addin backend is developed in rails, and I am using this gem for authentication. Im using this the omniauth microsoft graph gem for the microsoft authentication. In my addin, I use a dialog to get the /auth/microsoft_graph url and thus start the authentication process.
When I use the addin from the outlook standalone app, authentication runs smoothly and Im able to successfully log in. But if I try to open the addin on outlook for the web i get an CSRF error
I have tried setting
provider_ignores_state: true
int the omniauth.rb configbut that then gives a
NotImplementedError (no default_devise_mapping set):
error.Ive fixed that by setting a default devise mapping
And also setting a default resource class, since in my case its always going to be User.
But then it breaks when it tries to access the auth hash, because session is empty. I dont know why, the redirect_callbacks method is not correctly saving the session (only when it comes from the frame, from outlooks standalone app it works fine), as it says in this comment that it should do, so when the method
omniauth_success
is called, and then it tries to get the auth_hash, it raises an errorNoMethodError (undefined method `[]' for nil:NilClass):
Ive been investigating a bit more and I think it has to do with CSRF and the session store. I think that if the
provider_ignores_state: true
is set omniauth doesnt check CSRF and it doesnt raise the error, but the session store does check it and invalidates the session, thus not being able to complete the process. But if I dont use that option, omniauth checks the CSRF token and raises the error