I have a microservice app. hub.example.com
handles authentication. When a users logs in, I need to set a cookie on learn.example.com
What is a secure way to set this? I'm aware of a few approaches:
hub
sets the cookie onexample.com
This works, but the cookie propagates to other subdomains. Also a risky subdomain likelab
could set the cookie.learn
provides asetCookie
controller. Hub returns a redirect (or possibly a different mechanism) tolearn/setCookie?session=123
This works, but any domain (evenevil.com
) can use the controller.- The
setCookie
controller could verifyOrigin
and only allowhub
. I'm not quite sure what the usability and security consequences of this are. hub
contactslearn
direct with server-to-server authentication and get's a one-time token.hub
then sends a redirect to the user's browser tolearn/setCookie?token=token
(thanks to Fire Quacker)
Any suggestions about this would be most appreciated.
evil.com
. Using some sort of authentication between hub and learn seems the only way to do it. TOTP popped into my head first (with a shared seed and the token being passed as a URL parameter), but it's probably neither the easiest method nor the most efficient; it just popped into my head first.learn
a subdomain ofhub
?