How to Share the Same Authentication Session Between The App Studio and External Website

I’m trying to use the same login session between the app studio and my website. I noticed this happens automatically when using Google authentication. How can I achieve this natively without relying on third-party providers?

1 Answer

1

I guess it should work if both are hosted on the same domain as they can then share the auth cookie.

If not, I think you need an external auth provider as you already mentioned, which both then have to trust.

But maybe you can make Directus itself the auth provider using this openid extension. Related Github discussion

Didn’t use or try this tho, so big question if it’s working at all. Another hurdle might be to configure it seamless, so that you don’t have to redirect the user to the Directus/Openid server login page for authentication.

If both are hosted on the same root domain it should work, but your mileage may vary. Browsers are getting increasingly strict in sharing cookies between (sub)domains, so you might have to fiddle with some of the refresh cookie env vars

I tried using REFRESH_TOKEN_COOKIE_DOMAIN=.example.com and SESSION_COOKIE_DOMAIN=.example.com for example, but it caused me some issues with some other subdomains, can I select specific subdomains instead of the dot?

Passing on AI generated recommendation: :check_mark: Solution A — Create a shared parent domain Example: app.secured.example.com studio.secured.example.com Then limit the cookie to: Domain=.secured.example.com