gbv / login-server

Login and connect accounts with multiple identity providers
https://coli-conc.gbv.de/login/
MIT License
31 stars 32 forks source link

Allow running two instances of Login Server on same base domain #111

Closed stefandesu closed 9 months ago

stefandesu commented 9 months ago

Currently when running Login Server, the cookie is set for the base domain and path /. This means that if there are two parallel instances of Login Server on the same domain (let's say under /login-test1/ and /login-test2/), they will override each other's cookie and simply opening one will remove the cookie set by the other instance.

This could be easily circumvented by either using a unique cookie name for each instances (maybe based on namespace?), or by setting the cookie's path (although I will need to check if this has other consequences; I'm suspecting it won't be possible).

Edit:

The Path attribute indicates a URL path that must exist in the requested URL in order to send the Cookie header.

So we can't use Path.

Edit: From the express-session docs:

name

The name of the session ID cookie to set in the response (and read from in the request).

The default value is 'connect.sid'.

Note if you have multiple apps running on the same hostname (this is just the name, i.e. localhost or 127.0.0.1; different schemes and ports do not name a different hostname), then you need to separate the session cookies from each other. The simplest method is to simply set different names per app.

Edit:

stefandesu commented 9 months ago

I chose the easiest solution:

We can remove the session copy code in version 1.0 (if we someday get there).