Daylily-Informatics / bloom

Templated Abstract Polymorphic (and opinionated) LIMS
Mozilla Public License 2.0
0 stars 1 forks source link

Supabase Login Issues -- what runs on port 58080? #28

Closed iamh2o closed 7 months ago

iamh2o commented 7 months ago

I ran through the SUPABASE_CONFIG.md, and setup both github and google supabase services. Which appeared partially successful? When logging in via github and google, the appropriate login windows appear, and I can select my gh or goog user i wish to login as. However, then a chrome alert pops up telling me there was a github login error (even if I use the google login path).

chrome alert error:

localhost:8081 says
Failed to process GitHub authentication.

Poking in the code, this error is raised from this js:


                if (accessToken) {
                    // Send the code to the backend
                    fetch('http://0.0.0.0:58080/oauth_callback', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ accessToken: accessToken }),
                    })
                    .then(response => response.text())
                    .then(data => {
                        console.log("Response from server:", data);
                        alert(" authentication successful!");
                    })
                    .catch(error => {
                        console.error('Error:', error);
                        alert("Failed to process GitHub authentication.");
                    });
                } else {
                    console.log("No GitHub code found on home page.");
                }
            }

            window.onload = function() {
                checkForOauthCode();
            };
iamh2o commented 7 months ago

screenshot of the chrome console

bcon
iamh2o commented 7 months ago

I just merged a bunch of small changes into main (which is not stable exactly, but is now passing tests). Please pick up from there.

iamh2o commented 7 months ago

@jdurham38 -- UPDATE

I was not starting the fastapi server on port 58080, which was driving this error as the port had no service running on it!

NEW PROBLEM I can now authenticate with github and google.

Screenshot 2024-03-14 at 10 05 10 AM

However, the login session does not stick. After successful authorization, when I try to navigate to an auth required page, I get bounced back to login.

When I logout and then login via the user specified email route, this works.

iamh2o commented 7 months ago

Here is the uvicorn log for a successful auth via google

uvicorn main:app --reload --port 58080
INFO:     Will watch for changes in these directories: ['/Users/daylily/projects/daylily_repos/bloom']
INFO:     Uvicorn running on http://127.0.0.1:58080 (Press CTRL+C to quit)
INFO:     Started reloader process [3608] using StatReload
INFO:     Started server process [3610]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:55364 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:55364 - "GET /login HTTP/1.1" 200 OK
INFO:     127.0.0.1:55364 - "GET /logout HTTP/1.1" 303 See Other
INFO:     127.0.0.1:55364 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:55366 - "GET /admin?dest=skin HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:55366 - "GET /login HTTP/1.1" 200 OK
INFO:     127.0.0.1:55366 - "GET /assays?show_type=accessioning HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:55366 - "GET /login HTTP/1.1" 200 OK
INFO:     127.0.0.1:55379 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:55388 - "POST /oauth_callback HTTP/1.1" 303 See Other
INFO:     127.0.0.1:55388 - "GET / HTTP/1.1" 200 OK

And then if I try to visit assays, this is the log:


INFO:     127.0.0.1:55475 - "GET /assays?show_type=accessioning HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:55475 - "GET /login HTTP/1.1" 200 OK
iamh2o commented 7 months ago

Ok- It appears that the problem is in the redirect back to / following oauth. The request.session data is somehow cleared between the return from oauth and the redirect to /. This request.session is not reset using the direct email login path.

I checked in a few additional small tweaks to help debug this.

iamh2o commented 7 months ago

@jdurham38 --

I figured it out, when I modified this code

                if (accessToken) {
                    // Send the code to the backend
                    fetch('http://0.0.0.0:58080/oauth_callback', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ accessToken: accessToken }),
                    })

to not include 0.0.0.0:port, things work as expected

                if (accessToken) {
                    // Send the code to the backend
                    fetch('/oauth_callback', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ accessToken: accessToken }),
                    })