Skip to content
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: Allow to send authorization headers from web browsers using JavaScript clients #45809

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michalvavrik
Copy link
Member

@michalvavrik michalvavrik commented Jan 23, 2025

const urlSearchParams = new URLSearchParams(window.location.search);
const token = urlSearchParams.get("bearer")
const quarkusHeaderProtocol = encodeURIComponent("quarkus-header#Authorization#Bearer " + token)
socket = new WebSocket("ws://" + location.host + "/chat/" + username, ["bearer", quarkusHeaderProtocol]);

This comment has been minimized.

This comment has been minimized.

@michalvavrik
Copy link
Member Author

michalvavrik commented Jan 23, 2025

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.

@michalvavrik
Copy link
Member Author

I thought about it more and I'll drop closing: # issue because maybe we should follow up with different work, not sure if it will ever happen. Spring seems to have integration with SocketJS https://docs.spring.io/spring-security/reference/servlet/integrations/websocket.html#websocket-authorization-notes-messagetypes that does authentication when connection has been established, but that won't integrate with what we have now.

@sberyozkin
Copy link
Member

sberyozkin commented Jan 23, 2025

@michalvavrik Hi Michal,

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.

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

@michalvavrik
Copy link
Member Author

@michalvavrik Hi Michal,

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.

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.

@michalvavrik michalvavrik marked this pull request as draft January 23, 2025 11:31
@mkouba
Copy link
Contributor

mkouba commented Jan 23, 2025

@michalvavrik Hi Michal,

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.

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...

@michalvavrik michalvavrik force-pushed the feature/ws-next-show-how-propaate-bearere-with-legacy-js-cl branch 2 times, most recently from 68ae185 to f23301c Compare February 1, 2025 14:33
@michalvavrik
Copy link
Member Author

@sberyozkin @mkouba I reworked PR following Sergey suggestions, please have a look when the time is right for you. Thanks

@michalvavrik michalvavrik marked this pull request as ready for review February 1, 2025 14:34
@michalvavrik michalvavrik changed the title WebSockets Next: Show how to map request headers to Authorization header that OIDC Bearer token authentication require WebSockets Next: Allow to send authorization headers from web browsers using JavaScript clients Feb 1, 2025

This comment has been minimized.

@michalvavrik michalvavrik force-pushed the feature/ws-next-show-how-propaate-bearere-with-legacy-js-cl branch 4 times, most recently from 71d666a to a685f36 Compare February 1, 2025 14:56

This comment has been minimized.

This comment has been minimized.

Copy link

github-actions bot commented Feb 1, 2025

🎊 PR Preview 8b6a34f has been successfully built and deployed to https://quarkus-pr-main-45809-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

@sberyozkin
Copy link
Member

@michalvavrik LGTM, minor suggestions are proposed

@michalvavrik michalvavrik force-pushed the feature/ws-next-show-how-propaate-bearere-with-legacy-js-cl branch from a685f36 to 0ce801f Compare February 4, 2025 23:41
@michalvavrik
Copy link
Member Author

I think docs suggestions were great @sberyozkin , I applied them and found related changes. Should be better now.

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@sberyozkin sberyozkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it will make a real difference to those users who are struggling with finding solutions to pass tokens. Thanks

@mkouba Martin, please review as well

@michalvavrik michalvavrik force-pushed the feature/ws-next-show-how-propaate-bearere-with-legacy-js-cl branch from 0ce801f to ff7436e Compare February 6, 2025 14:17
Copy link

quarkus-bot bot commented Feb 6, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit ff7436e.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

You can consult the Develocity build scans.

Copy link

quarkus-bot bot commented Feb 6, 2025

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit ff7436e.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants