-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
WebSockets Next: Show how to map request headers to Authorization header that OIDC Bearer token authentication require #45809
base: main
Are you sure you want to change the base?
Conversation
Status for workflow
|
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✖ | Documentation Build | Build |
Logs | Raw logs | 🚧 |
I'll not waste CI resources and fix docs build failure till I hear from reviewers because I have feeling this could go many ways, maybe even closing this PR completely. |
==== Bearer token authentication | ||
|
||
The xref:security-oidc-bearer-token-authentication.adoc[OIDC Bearer token authentication] expects that bearer tokens are passed in the `Authorization` header during the initial HTTP handshake. | ||
While we recommend to use WebSocket clients that support setting custom headers in the initial HTTP handshake, there are users that rely on https://websockets.spec.whatwg.org/#the-websocket-interface[WebSockets API]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding that anyone writing JavaScript-based WS applications has no choice but to use that API, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it makes sense to have 2 sub-sections, one for WS Client, another for WS API, right now it reads like using WS API is quite a bad idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding that anyone writing JavaScript-based WS applications has no choice but to use that API, right ?
My understanding is there are some JS clients that also implements WS and supports that. One that seem mostly trustworthy is websockets/ws#1925 (pointing to the issue because it is clear they are setting headers on the client side) https://github.com/websockets/ws/blob/master/lib/websocket.js#L743. The issue with this is that some users think like I would: do my employer trust this in production and why?
IMHO it makes sense to have 2 sub-sections, one for WS Client, another for WS API, right now it reads like using WS API is quite a bad idea
I thought we need to make very clear line between what is possible and what we suggest (nothing, you are on your own). We can use to use WebSockets API, but I think it requires additional concepts like CORS and custom protocol that has message types and we would authenticate on one of these message types. If you have idea, please suggest specific test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalvavrik IMHO it makes sense to make it clear how users who have no other option but to use WS API can approach it, as opposed to us discouraging them, with some warnings added.
Look at Quarkus LangChain4j demos, chatbots are everywhere, opened from scripts, they can't use Quarkus Java WS Client.
We should not be recommending specific JS client libraries, as under the hood the probably do these workarounds anyway, and I agree, we don't want to take risk and guide users to use specific libraries and then be asked why did we do it...
As far as using WS API is concerned, we should give simple suggestions:
- Use sub-protocol, I'm not sure it is still the case but it was definitely done in Kubernetes as well: kubernetes/kubernetes@714f97d
- Recommend custom ticketing system to mitigate the absence of the CORS control: https://github.com/quarkiverse/quarkus-langchain4j/blob/main/samples/secure-sql-chatbot/README.md#custom-websocket-ticket-system, https://github.com/quarkiverse/quarkus-langchain4j/blob/main/samples/secure-sql-chatbot/src/main/java/io/quarkiverse/langchain4j/sample/chatbot/TicketHttpUpgradeCheck.java
- Ask users to use
wss:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense @sberyozkin , I'll rewrite this later in the afternoon. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @michalvavrik, take your time please
private static final String TOKEN_PREFIX = BEARER_PROTOCOL + ","; | ||
void observe(@Observes Router router) { | ||
router.get().order(-250).handler(routingContext -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, would it make sense for WS-Next provide such a handler for users not having to write this code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #42824 (comment), it can be discussed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO optionally enabling a handler which does a header conversion according the documented scheme is all right, it is not a workaround for users who have to use WS API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think it would be easier to understand than ask users to add this handler. We must be clear in docs about security aspects, that's all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we just explain what users who really need to retain tokens can do, may be we can offer some basic support like having this handler enabled if requests, and ask users take WS API security concerns seriously
I thought about it more and I'll drop |
@michalvavrik Hi Michal,
It should definitely not be closed, it is a step in the right direction, this is the most often asked question, how to get the token passed from Java Script WS API, thanks for initiating this work, it is a big deal, IMHO, it might need a bit more work, but I'm actually very positive about your PR. By the way, setting it to Draft is the right way if you expect a few iterations with the PR |
Thanks Sergey, I can make it draft, but yesterday I took it as far as I can without feedback. So I feel like I need @mkouba and @sberyozkin to comment when you have time. |
I'll take a look tomorrow... |
that is not in the content of this PR because I don't suggest it, users have proper way to get tokens, I just give you steps to test this PR