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

Refactor websocket code to $oh namespace & Pass access token through header #2907

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Dec 9, 2024

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.

@florian-h05
Copy link
Contributor Author

@ghys This refactors the WS to the $oh namespace.
Let's postpone merging this after the release to not impose any risks.

Copy link

relativeci bot commented Dec 9, 2024

#2582 Bundle Size — 10.9MiB (~+0.01%).

d5203ea(current) vs 0ead7b8 main#2579(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#2582
     Baseline
#2579
Regression  Initial JS 1.92MiB(+0.08%) 1.92MiB
No change  Initial CSS 577.83KiB 577.83KiB
Change  Cache Invalidation 17.65% 17.58%
No change  Chunks 226 226
No change  Assets 249 249
Change  Modules 2948(+0.03%) 2947
No change  Duplicate Modules 152 152
No change  Duplicate Code 1.8% 1.8%
No change  Packages 96 96
No change  Duplicate Packages 2 2
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#2582
     Baseline
#2579
Regression  JS 9.11MiB (+0.01%) 9.11MiB
No change  CSS 866.74KiB 866.74KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 140.74KiB 140.74KiB
No change  HTML 1.38KiB 1.38KiB
No change  Other 871B 871B

Bundle analysis reportBranch florian-h05:ws-rfcProject dashboard


Generated by RelativeCIDocumentationReport issue

@florian-h05 florian-h05 force-pushed the ws-rfc branch 2 times, most recently from 89e59d9 to d9ba1a5 Compare December 17, 2024 15:09
Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 marked this pull request as ready for review December 17, 2024 15:29
@florian-h05 florian-h05 requested a review from ghys as a code owner December 17, 2024 15:29
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Dec 17, 2024
@florian-h05 florian-h05 added this to the 5.0 milestone Dec 17, 2024
@florian-h05
Copy link
Contributor Author

@ghys Can you please have a look at this PR?

Copy link
Member

@ghys ghys left a comment

Choose a reason for hiding this comment

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

It's good but I'd still prefer the access token to be passed in headers instead of the URL query: openhab/openhab-core#4490
(at least when possible)

This reduces the odds that it could appear in a log.
Even if ephemeral, tokens should never be logged.

If it's urgent please merge but otherwise I don't see why the rush.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 changed the title Refactor websocket code to $oh namespace Refactor websocket code to $oh namespace & Pass access token through header Dec 22, 2024
@florian-h05 florian-h05 added the awaiting other PR Depends on another PR label Dec 22, 2024
@florian-h05
Copy link
Contributor Author

@ghys I have created a PR to address openhab/openhab-core#4490 and adjusted this PR here.

@florian-h05 florian-h05 marked this pull request as draft December 22, 2024 14:23
@florian-h05 florian-h05 marked this pull request as ready for review December 31, 2024 16:01
@florian-h05 florian-h05 removed the awaiting other PR Depends on another PR label Dec 31, 2024
@florian-h05 florian-h05 merged commit 85616e1 into openhab:main Dec 31, 2024
6 checks passed
@florian-h05 florian-h05 deleted the ws-rfc branch December 31, 2024 16:02
@ghys
Copy link
Member

ghys commented Jan 2, 2025

Excellent, thanks!

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jan 4, 2025
Follow-up for openhab#2907.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
florian-h05 added a commit that referenced this pull request Jan 4, 2025
Follow-up for #2907.

Fixes WS client broken due to `=` being part of the base74-encoded
token, which is no allowed WS subprotocol value.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@cdjackson
Copy link
Contributor

@florian-h05 is it possible to provide backward compatibility with the old url parameter based authentication so we can continue to run this on OH4 for a while? I've got an OH5 test system which is fine for testing UI, but it would really be nice for now if we can also proxy this across to a live OH4.x system, and currently that doesn't work after this change.

I tried adding the parameter back (so putting the token in both the header and parameter) and that didn't work - I had to remove the header to make it work on OH4.

I think it would be good to keep compatibility for testing for a little while at least if possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants