-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication with multiple JWT tokens from the same browser session #387
Comments
For now, I've made a workaround via a reverse-proxy configuration in my nginx
|
@dunglas 👋, Given a lot of issues with event-source-polyfill, is there any possibility that this feature* might come with v0.11? * Defining JWT key in URL parameters. It's still secure and tampered data can be easily detected. The only limitation is increased URL size. Thanks! |
I'm not against supporting this feature in the hub. But I'm not sure if it should be in the spec. Maybe should we make supporting this feature only as a "MAY" in the spec? |
I suggest to add support for query parameters in spec. We can adapt the wording of the OAuth spec: https://tools.ietf.org/html/rfc6750#section-2.3 |
@dunglas 👋, that would be really great! Thanks! |
@dunglas nice! I'm looking forward for an update. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I just opened a PR to add support for this to the spec, could you review please? #562 |
Seems legit, as you have proposed, the hubs Also, I've had an idea while reviewing these changes: How about alowing the subscriber to specify which cookie is to be used for authentication? I'm gonna quote a portion of the initial comment:
This is only true if only one specific cookie is used for authentication of subscribers. If the subscriber could tell the hub to read the JWS from any specific cookie at the time the connection is established, via a query parameter (i.e. The above specific cookie "method" would preserve the security level you were pursuing from the beginning while still adding the multi-client feature. I'm sorry I did not think of this earlier. I'm not saying you should completely remove the query authentication method. It is really a convenient way to implement it, and the |
Hello, Query parameter authentication was requested (by me as well) only because of the lack of native support for authentication headers in SSE. That's why we're using event-source-polyfill which has some random issues (timeouts and etc) and it's not native overall.
Do you have any example specs that do the same thing? For me specifying cookie name in query parameters doesn't make sense. It will make things messy and what I have seen in all eco systems is that cookie names are configured once and never touched again. Never thought that cookie names might become a dynamic one... Thanks! |
Hey, no, I have no specs nor implementations of such behaviour. As said, i've had the idea just when I was reading through the PR where a Agreed, it would be a highly uncommon practice to do so. But nevertheless, functionality would be there and it would preserve the security (i.e. not expose the JWS in the URL). |
@damijank Did you find a solution to this? It seems from the docs that passing the authentication on the URL query does work now: But as others said, no ideal security wise since the token will be logged in requests. One solution, assuming you are controlling the domains, is creating a subdomain in the DNS for those names that point to your hub. Cookies in the subdomain should be supported. |
Also looking to run it as reverse proxy, in the docs it says that authorization is only supported using HTTPS, does that apply as well using a reverse proxy? The proxy would handle the HTTPS and certificate connection, are you still running the hub with HTTPS internally if that is the case? |
I have in the meantime moved away from the project for which this feature has been requested. But this was the (a) solution to our use case... so yeah, I found it even before asking for the feature... 🙂 As the hub has implemented the support for query parameter authorization, I have notified my successor there... but did not follow up with them if it was implemented though.
If one would add a separate subdomain for every client, then this would be okay... but that was not the case in the project, an arbitrary number of clients can be added, programmatically, so we needed a dynamic solution.
Yes, it applies. As you said yourself, the hub requires a direct HTTPS connection when authorization is used. The reverse proxy only "moves" the token from the query parameter to the cookie. Then the request is forwarded to the hub via HTTPS. If you have a similar scenario to that what I have described (a single hub domain, manage multiple clients from a single browser session), and you would really want to protect your JWT, you could do some "black magic" like I described in a comment above
It could be something like
I did not test this, it may not work as it is, I wrote from top of my head. I don't know if we can use a variable for the map pattern. You may find a more elegant solution, but this kinda demonstrates it. |
I have a question about serving multi-tenant / multi-client apps.
We have a setup like this one:
paas.org
)tenant.org
domain)client-one.org
,client-two.org
...)For reference:
in this setup the tenants (our customers) are parents of clients (our customers have multiple websites, mobile apps, etc.).
When working just with a single client, we ran into the problem that the client and the hub are not on the same second-level domain. I've seen #17 and the polyfill solution is not what we would want since that falls back to plain ol' HTTP and as such is not as "native" and performant as the real native
EventSource
.We could/should fix this with the PaaS setting the
mercureAuthentication
cookie at the time of response to OAuth, and since the hub is on the same domain this should work... almost, I'm not going into detail with OAuth scopes. But still, even that is not the whole story. 🙂When switching to a second client in the CMS, it has to fetch a different JWT from PaaS (which would reset the cookie), then the CMS opens a new
EventSource
connection to the hub with the new JWT.With the solution when the PaaS sets the mercure cookie, we here loose the
EventSource
connection for the first client.If we exposed the header to JS, it still wouldn't work because JS can not set a cookie for another domain (it's not a subdomain, so a
Domain
attribute isn't suitable either).We want to enable the customer to have multiple tabs with CMS open in the same browser session, each administering it's own client. With cookie-based mercure authentication we can not have each tab receiving it's own SSEs because the cookie can only be set to a single value.
I've found this #150 and I understand the goal of securing the JWT. But in the end, with HTTPS the URI itself is encrypted in transport. I'd suggest to add a query parameter as a possibility for mercure authentication. The current limitation is restrictive enough so we're not able to accomplish what we've aimed for.
I'm open to any other suggestions which would resolve this problem, without the need to transport the JWT in a query parameter. Please advise!
The text was updated successfully, but these errors were encountered: