Logout endpoint #125
Replies: 4 comments 4 replies
-
If you need a custom setup it’s easier to do it in your action, strategies are free to expose more methods for app developers to use them. The logout method that comes with Remix Auth is mostly a helper for the majority of the use cases than something you need to do, it’s a few lines of code anyway. |
Beta Was this translation helpful? Give feedback.
-
Yes, the way I am handling it right now is (pasting it in case it is useful to somebody else):
A logout method that does this could be added to the Auth0 strategy, so that the user could call it instead of Although, IMHO it may be a little cleaner to delegate the logout to the strategy somehow as well. I was thinking on implementing a Cognito strategy. If I remember correctly, it would need to do that too. Both options work, though. |
Beta Was this translation helpful? Give feedback.
-
I wish this was mentioned somewhere more accessible, since I've spent the entire morning trying to figure out why authenticator.logout didn't log me out from Auth0. |
Beta Was this translation helpful? Give feedback.
-
@sergiodxa @gusajz @designbyadrian I added issues in both the oauth2 and auth0 strategy repos: sergiodxa/remix-auth-oauth2#15 |
Beta Was this translation helpful? Give feedback.
-
Auth0 (but probably other IdPs too) requires redirecting to a specific endpoint upon logout.
Right now,
remix-auth
just destroys the cookie (without any strategy intervention). Since Auth0 doesn't know, it does not destroy its own cookie. The result is that if the user had logged in using a social connector, for example, during the next login attempt, Auth0 will log them in using the same connector and credentials without asking again.The solution, in Auth0 case, is the redirect to
/v2/logout?client_id=${clientId}&returnTo=${redirectTo}
.In order to do so,
remix-auth
should let the used strategy do it (or build the redirect URL).I can think of three different approaches:
remix-auth.logout
delegates the work to the strategy. To avoid breaking other strategies, a default implementation would be provided in theStrategy
base class. One drawback is that the strategy would be responsible for destroying the cookie.remix-auth.logout
asks the strategy to build the redirect URL. I am not sure if other identity providers would have any other requirement beside redirecting to a specific endpoint, though.Any thoughts?
I have a working solution to make a PR.
PS: Thanks for the great work creating this library. It's been a pleasure to work and extend :).
Beta Was this translation helpful? Give feedback.
All reactions