ForestAdmin / forest-rails

💎 Ruby on Rails agent for Forest Admin to integrate directly to your existing Ruby on Rails backend application.
https://www.forestadmin.com
GNU General Public License v3.0
371 stars 76 forks source link

google login fails: forest/sessions-google route not found #362

Open emmanuelcohenlaroque opened 4 years ago

emmanuelcohenlaroque commented 4 years ago

Expected behavior

Google login should allow login from ForestAdmin

Actual behavior

Login fails

Failure Logs

I, [2020-06-03T05:37:15.956952 #32183] INFO -- : [263cb676-68b7-4c7c-a54c-4f456fd08d71] Started GET "/forest/sessions-google" for 82.64.230.221 at 2020-06-03 05:37:15 +0000 I, [2020-06-03T05:37:15.983649 #32183] INFO -- : [263cb676-68b7-4c7c-a54c-4f456fd08d71] Processing by ForestLiana::ApplicationController#route_not_found as HTML I, [2020-06-03T05:37:15.983722 #32183] INFO -- : [263cb676-68b7-4c7c-a54c-4f456fd08d71] Parameters: {"collection"=>"sessions-google"} I, [2020-06-03T05:37:16.101472 #32183] INFO -- : [263cb676-68b7-4c7c-a54c-4f456fd08d71] Filter chain halted as :authenticate_user_from_jwt rendered or redirected I, [2020-06-03T05:37:16.101816 #32183] INFO -- : [263cb676-68b7-4c7c-a54c-4f456fd08d71] Completed 401 Unauthorized in 118ms (ActiveRecord: 0.0ms) I, [2020-06-03T05:37:36.898805 #32183] INFO -- : [4d62e9a5-dc1f-4e7f-8e5f-312b35417734] Started GET "/forest/sessions-google" for 82.64.230.221 at 2020-06-03 05:37:36 +0000 I, [2020-06-03T05:37:36.900523 #32183] INFO -- : [4d62e9a5-dc1f-4e7f-8e5f-312b35417734] Processing by ForestLiana::ApplicationController#route_not_found as HTML I, [2020-06-03T05:37:36.900615 #32183] INFO -- : [4d62e9a5-dc1f-4e7f-8e5f-312b35417734] Parameters: {"collection"=>"sessions-google"} I, [2020-06-03T05:37:36.901202 #32183] INFO -- : [4d62e9a5-dc1f-4e7f-8e5f-312b35417734] Filter chain halted as :authenticate_user_from_jwt rendered or redirected I, [2020-06-03T05:37:36.901368 #32183] INFO -- : [4d62e9a5-dc1f-4e7f-8e5f-312b35417734] Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms) I, [2020-06-03T05:37:43.833556 #32183] INFO -- : [f7ea0af1-6035-47c3-aafa-7978726bb54e] Started GET "/forest/sessions-google" for 82.64.230.221 at 2020-06-03 05:37:43 +0000 I, [2020-06-03T05:37:43.834995 #32183] INFO -- : [f7ea0af1-6035-47c3-aafa-7978726bb54e] Processing by ForestLiana::ApplicationController#route_not_found as HTML I, [2020-06-03T05:37:43.835085 #32183] INFO -- : [f7ea0af1-6035-47c3-aafa-7978726bb54e] Parameters: {"collection"=>"sessions-google"} I, [2020-06-03T05:37:43.835624 #32183] INFO -- : [f7ea0af1-6035-47c3-aafa-7978726bb54e] Filter chain halted as :authenticate_user_from_jwt rendered or redirected

Context

Using a rails app as backend, with forest-rails gem.

arnaudbesnier commented 4 years ago

Hi @ecl66,

Thanks for the report. Did you use another gem version before the issue started to occur? (ie vo you think this is a recent regression?)

What is strange is that the creation of a session using Google SSO is made with a POST method, not a GET as it is presented in the error trace. Can you detail what are the exact steps / actions you did to have this issue?

Thanks for your help 🙏

emmanuelcohenlaroque commented 4 years ago

Thanks Arnaud. We have not changed our rails backend at all and the issue started recently (say a couple of months). Our server is hosted as a proxy on Nginx and https if that helps. I launched Lumbar on that same server and it works ok. But we need to get it working again on rails. Bonne journée

arnaudbesnier commented 4 years ago

I didn't not get why there is a mix of Lumber and Rails server in your architecture. If your intent is to have Forest Admin UI plugged on your Rails server, there should be no usage of Lumber in my opinion.

Once again, the Admin API hosted by the Forest Admin gem does not expect to receive a: GET /forest/sessions-google but a: POST /forest/sessions-google

I don't know where does this GET request comes from but it does not comes from the Forest Admin client. Can you please share a screencast (using loom for instance) of the interactions you did in the Forest Admin client to have this error.

Thanks

emmanuelcohenlaroque commented 4 years ago

We don’t have a mix of rails and lumber, just that I wanted to ensure the web server was not an issue!

emmanuelcohenlaroque commented 4 years ago

Just trying to login with Google generates this error on the server: Started GET "/forest/healthcheck" for 82.64.230.221 at 2020-06-03 10:05:16 +0000 I, [2020-06-03T10:05:16.654514 #32183] INFO -- : [e8f6fcea-4f1a-4e00-a93e-a3394473c495] Processing by ForestLiana::ApplicationController#route_not_found as / I, [2020-06-03T10:05:16.654608 #32183] INFO -- : [e8f6fcea-4f1a-4e00-a93e-a3394473c495] Parameters: {"collection"=>"healthcheck"} I, [2020-06-03T10:05:16.655175 #32183] INFO -- : [e8f6fcea-4f1a-4e00-a93e-a3394473c495] Filter chain halted as :authenticate_user_from_jwt rendered or redirected

arnaudbesnier commented 4 years ago

According to our internal data, your "admin" environment is not setup with Rails but with Lumber (Node.js app). Your other environments run with the Rails gem.

Doing a curl on your admin environment endpoint works well on my side, I receive a 200 response: curl -i https://forest.yourdomain.co/forest/healthcheck.

Now I think I get why you have a Lumber generated environment, I guess you followed the new environment creation process in the project environments settings. We might have an issue with Rails projects because it is made for Lumber generated projects.

emmanuelcohenlaroque commented 4 years ago

Arnaud: we have two environments and two domains: forest.domain... which is Lumbar(ADMIN) and admin.domain which is Rails (named RAIL). They are distincts. The Lumbar domain was created while the issue with the Rails persists. The Rails env was created using Rails only and was not mixed up with the Lumbar one. May be I need to regenerated another clean Rails env but it does not seem possible any longer with the ForestAdmin interface, is it?