Hubs-Foundation / hubs-cloud

Resources for self hosted Hubs Cloud instances
Mozilla Public License 2.0
149 stars 88 forks source link

Resolving discord bot authentication for Hubs Cloud implementation on AWS #302

Open JUGERNAUTUS opened 2 years ago

JUGERNAUTUS commented 2 years ago

Hi Hubs Team,

I would be willing to take this up and provide a resolution at my end. I'm new to Elixir and Reticulum and a bit green with AWS but willing to put in the hours to make this work if required

Summary of my request: How I can see reticulum logs in debug mode or monitor request/response to the public internet on AWS? Anything else that would help me debug and resolve this

Im able to get the discord bot working and generate a link for the room. However Im not able to proceed past discord authentication. This is my understanding of the issue till now -

When the user click on the room link generated by the bot and then it asks for a discord authentication and authorization, after authorization, discord sends a code and state params to the redirect url. Reticulum is expected to swap this code for an access token by hitting the discord token URL endpoint (https://discord.com/developers/docs/topics/oauth2). This access token is then supposed to be included in the header of all page requests to hubs.

This functionality works fine for the mozilla hubs (hubs.mozilla.com) setup. The user is able to do a discord authentication and sign in using the Hubs Mozilla bot and if you check the request header, it contains an access token after hitting the redirect url, in the page request.

Unfortunately if you are running a stand alone implementation of Hubs Cloud, the App server API endpoint seems to be unable to receive an access token. If you check the rerouting to the Hubs page after you authorize discord, the access token is missing in the header, hence hubs cloud again asks you to authorize and authenticate with discord

I can see in the Syslog that reticulum is making the request to discord token url to swap the code for the access token. I can also verify that the code has been swapped on discord's end. (If you try to do the swap with postman, it says 'invalid code' - the code has been already swapped). I'm not sure if reticulum is actually receiving the access token, and if it is, why it is not including it in the rerouted request to the hubs page.

Any suggestions from your side that help debug and resolve this issue are helpful. Thanks!

wsxiaoys commented 2 years ago

It can be fixed with workaround described in https://github.com/mozilla/hubs-cloud/issues/295

JUGERNAUTUS commented 2 years ago

It can be fixed with workaround described in #295

Thanks! This worked for me