Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Logout doesn't work #3

Open
licht1stein opened this issue Jun 25, 2024 · 23 comments
Open

Logout doesn't work #3

licht1stein opened this issue Jun 25, 2024 · 23 comments

Comments

@licht1stein
Copy link

Hi,

Everything works in development, but when deployed logout doesn't seem to do anything, and neither does deleting all the cookies. Here's the app initialization:

(defmethod ig/init-key :sidework/server [_ {:keys [port] :as opts}]
  (println ::init :port port)
  (let [app (make-app opts)]
    (serv/run-server (-> app
                           (garden-id/wrap-auth)
                           (session/wrap-session {:store (cookie-store)})) (select-keys opts [:port]))))

And here's the deployed app: https://sidework.apps.garden

Please advise what am I doing wrong?

@licht1stein
Copy link
Author

It seems to be related to CORS:

image

@leahneukirchen
Copy link
Contributor

leahneukirchen commented Jun 25, 2024

That link should be visited as a regular link, not using AJAX.

This is because you use hx-boost on the whole page.

@leahneukirchen
Copy link
Contributor

But something else seems to be wrong, as I was logged in as @zampino when I opened that page the first time oO

@licht1stein
Copy link
Author

Removing hx-boost fixed the CORS error, but didn't log me out.

@licht1stein
Copy link
Author

But something else seems to be wrong, as I was logged in as @zampino when I opened that page the first time oO

That is seriously strange :)

@licht1stein
Copy link
Author

A lot of things are happening when I click logout, but logging out is not one of them:

Screen.Recording.2024-06-25.at.15.10.36.mov

@jackrusher
Copy link

In addition to the "wrong user" horror, I was unable to login with Apple creds at all

@jackrusher
Copy link

(Thanks for reporting, @licht1stein! This stuff is very early 😆)

@licht1stein
Copy link
Author

@jackrusher I'm very glad to help!

@leahneukirchen
Copy link
Contributor

Your app redirects to the login when there's not user in the session...

@licht1stein
Copy link
Author

Sure, cause you need to be logged in to use it.

@licht1stein
Copy link
Author

This is the middleware that does it:

(defn login-checker
  [handler]
  (fn [{:keys [app/db] :as request}]
    (if-let [user (garden-id/get-user request)]
      (handler (assoc request :app/user (users/ensure-user db {:user/email (:email user)
                                                               :user/name (:name user)})))
      (redirect garden-id/#-uri))))

@leahneukirchen
Copy link
Contributor

But there is no login dialog if you are already logged in at application.garden, so it transparently logs you in again...

@licht1stein
Copy link
Author

True, but I expected to see this:

image

@licht1stein
Copy link
Author

Well, not the impersonate part. The enter your credentials part. So the user is logged out of my site, but not logged out of the OIDC, and that's why they get back in.

But if user pressed logout, they probably should be prompted to confirm logging back in?

@leahneukirchen
Copy link
Contributor

You need to visit https://#.auth.application.garden/logout, then you need to reauthenticate to log in

@licht1stein
Copy link
Author

You need to visit https://#.auth.application.garden/logout, then you need to reauthenticate to log in

So this should be the logout link instead of garden-id/logout-uri?

@leahneukirchen
Copy link
Contributor

This will log out the user of every garden app, so imo no.

@licht1stein
Copy link
Author

I mean, I can go around this limitation by adding a /# page to my app, that will have a big friendly login button. But I have a feeling that the entire flow is a bit non-intuitive at the moment.

In addition to non-intuitive part, every garden user goes around transmitting their personal data to every garden.app, even if they never wanted to use it. This doesn't feel right.

@licht1stein
Copy link
Author

licht1stein commented Jun 25, 2024

My expectation of a website is that the moment I press "Logout" I'm using it as an anonymous user. This isn't the case with garden-id, right?

For this app it's no problem — I wanted to make a public home page anyway, and I can redirect to the public homepage later. But I wouldn't be comfortable with putting this into a client's app.

@leahneukirchen
Copy link
Contributor

If you press logout, there's no session anymore to identify you, so it's an anonymous user.

The thing is that you are logged in automatically if you redirect to the login endpoint.

We should probably make an interstitial there to at least ask if the user logs in to an app they have not used before. (C.f. how github does it.)

@jackrusher
Copy link

@leahneukirchen let's add that interstitial

@zampino
Copy link
Contributor

zampino commented Jul 10, 2024

Would it make things easier/different if we'd store the name of the app (from the container's env var) on the session after the successful OIDC callback, and make the garden-id/logged-in? check more than just the "global" user?

(some? (get-user req)))

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants