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

Widget actions: Add a HTTP action to perform HTTP requests #2711

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Aug 13, 2024

This allows to perform HTTP requests from inside widget actions.
The use case might be limited, but for example this can be used to allow access to local only ressources/smart devices that should not be made available via remote access and hence cannot be integrated as Items into openHAB for security purpose.

@florian-h05 florian-h05 requested a review from a team as a code owner August 13, 2024 11:13
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Aug 13, 2024
@florian-h05 florian-h05 added this to the 4.3 milestone Aug 13, 2024
Copy link

relativeci bot commented Aug 13, 2024

#2189 Bundle Size — 10.82MiB (~+0.01%).

4f7e22f(current) vs f745fa9 main#2188(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#2189
     Baseline
#2188
Regression  Initial JS 1.89MiB(+0.04%) 1.89MiB
No change  Initial CSS 576.5KiB 576.5KiB
Change  Cache Invalidation 17.42% 17.81%
No change  Chunks 226 226
No change  Assets 249 249
No change  Modules 2914 2914
No change  Duplicate Modules 149 149
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
#2189
     Baseline
#2188
Regression  JS 9.04MiB (~+0.01%) 9.04MiB
No change  CSS 862.88KiB 862.88KiB
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.24KiB 1.24KiB
No change  Other 871B 871B

Bundle analysis reportBranch florian-h05:action-httpProject dashboard


Generated by RelativeCIDocumentationReport issue

@florian-h05 florian-h05 merged commit a13ffe3 into openhab:main Aug 13, 2024
8 checks passed
@florian-h05 florian-h05 deleted the action-http branch August 13, 2024 11:19
@florian-h05
Copy link
Contributor Author

@ghys Thanks for your feedback.
WRT to CSP: I see that Main UI already has a CSP, do you think we can adjust it in a way that a user cannot load scripts from external servers?

@florian-h05
Copy link
Contributor Author

Okay we can use CSP to limit to which domains a request can be sent by this action.
Should we limit that and advise users that want to use this action to overwrite our CSP by setting the header on a reverse proxy?

@florian-h05
Copy link
Contributor Author

Okay this seems to be very restrictive and not super user-friendly ...

@ghys
Copy link
Member

ghys commented Aug 15, 2024

I totally forgot there was already a CSP...

I wonder if we could have a configurable whitelist of allowed domains that would alter the CSP - maybe by generating the index.html dynamically.
Ideally it would not be configurable remotely, like the whitelist of the exec binding.

@florian-h05
Copy link
Contributor Author

maybe by generating the index.html dynamically.

I think it is actually easier than that:
We can set the CSP as a header (and keep the one in the index.html as fallback — the header is prioritised over the meta tag) in the UI’s servlet, where we of course can do this programmatically.

However we need to figure out how to provide the list of allowed domains in a file-only config … it should help to have a look at the code of the exec binding (https://github.com/openhab/openhab-addons/blob/e62f3af4c7173145f6f2742e3a88631f5c5fdbb8/bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/ExecWhitelistWatchService.java#L41).

@ghys
Copy link
Member

ghys commented Aug 15, 2024

We can set the CSP as a header

Ah yes indeed... so maybe via a derived servlet to serve that index page (and the rest, possibly) - or equivalent.

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.

2 participants