-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
[websocket] Support token authentication through header #4515
Merged
holgerfriedrich
merged 2 commits into
openhab:main
from
florian-h05:websocket-auth-header
Dec 31, 2024
Merged
[websocket] Support token authentication through header #4515
holgerfriedrich
merged 2 commits into
openhab:main
from
florian-h05:websocket-auth-header
Dec 31, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ol header Signed-off-by: Florian Hotze <dev@florianhotze.com>
florian-h05
force-pushed
the
websocket-auth-header
branch
from
December 22, 2024 14:07
19ec9f0
to
164291a
Compare
@ghys This was easier to implement than I expected 👍 |
@florian-h05 you're underestimating yourself ;) |
...ab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/CommonWebSocketServlet.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Hotze <dev@florianhotze.com>
holgerfriedrich
approved these changes
Dec 31, 2024
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.
LGTM, thanks!
florian-h05
added a commit
to openhab/openhab-webui
that referenced
this pull request
Dec 31, 2024
…h header (#2907) Depens on openhab/openhab-core#4515. This refactors the WebSocket connection code from #2884 to the `$oh` namespace, same as it is for the SSE logic. It also passes the access token as WebSocket subprotocol so it is sent with the `Sec-WebSocket-Protocol` header. --------- Signed-off-by: Florian Hotze <dev@florianhotze.com>
florian-h05
added a commit
to florian-h05/openhab-docs
that referenced
this pull request
Jan 4, 2025
Refs openhab/openhab-core#4515. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05
added a commit
to florian-h05/openhab-docs
that referenced
this pull request
Jan 4, 2025
Refs openhab/openhab-core#4515. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05
added a commit
to florian-h05/openhab-docs
that referenced
this pull request
Jan 4, 2025
Refs openhab/openhab-core#4515. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
stefan-hoehn
pushed a commit
to openhab/openhab-docs
that referenced
this pull request
Jan 5, 2025
…2442) * WebSocket API: Add sending access token through sub-protocols header Refs openhab/openhab-core#4515. Signed-off-by: Florian Hotze <florianh_dev@icloud.com> * Update configuration/websocket.md Signed-off-by: Florian Hotze <dev@florianhotze.com> --------- Signed-off-by: Florian Hotze <florianh_dev@icloud.com> Signed-off-by: Florian Hotze <dev@florianhotze.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #4490.
Browser clients do not have the ability to set an
Authorization
header programatically on websocket requests. All they have control over is the URL and the websocket subprotocols sent (see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)This PR adds support for specifying a bearer token via a websocket subprotocol, with the format
org.openhab.ws.accessToken.base64.<encoded-token>
.The browser must specify at least one other subprotocol since the server must echo a selected subprotocol back.
For this,
org.openhab.ws.protocol.default
is used.<encoded-token>
must be base64-encoded without padding, since bearer tokens can contain characters a websocket protocol may not (/
and=
).