Closed Confectrician closed 3 years ago
@Confectrician If you have the ability to set headers in the HTTP request, perhaps you can set the Authorization: header using the Basic authentication scheme.
https://en.wikipedia.org/wiki/Basic_access_authentication
For example
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Where QWxhZGRpbjpPcGVuU2VzYW1l
is the base64 encoding of the user id and password. I've done this in Java like this. Unfortunately, I don't know how to do this in VS Code.
new String(Base64.getEncoder().encode(("userId" + ":" + "userPassword").getBytes()),
StandardCharsets.UTF_8);
Hey @mhilbush,
Thanks for jumping in.
I know those auth headers, but theres one problem for now. Currently we are not making any http call ourselfs.
See: https://github.com/openhab/openhab-vscode/blob/master/client/src/WebView/PreviewPanel.ts#L207
Its just an iframe with a generated url in its attribute.
Anyways this is a valid approach we should check, Maybe we could load the empty view and make some call through javascript afterwards, including such a auth header.
We have choosen an iframe on purpose to deliver the whole BasiUI as is and get a dynamic usable UI into vscode. This is especially important, when one wants a previw for some nested Sitemap elements, so i would call the dynamic stuff necessary. Any solution we try should fulfill this requirement.
Currently we are not making any http call ourselfs.
Ah, yes, I see. I was worried there might be some obstacles to using auth headers...
I will definitely look into this, but as you see that will be no oneliner. I was also already thinking about additional possibilities for those webviews.
Hey @Confectrician, did you had a chance to have a look into this issue. Also facing this problem. When commenting out openhab.username and openhab.password, then it is completely working fine. Would be great to hear good news. Thanks in advance, Patrick
Nope. I was busy with binding development last time.
I have checked some more options for implementing a workaround, but i have found none.
So there is no simple solution from my side. Sorry. I am thinking about deactivating the basic ui webview when basic ui is configured or show something like a "sorry doesn't work" page.
Things one could do: Configure a special reverse proxy route for configuration in openHAB
Another thing that would be possible, is to introduce a new setting, which will open basic ui preview in browser too.
So to do a preview I use another extention
Start URI is http://openhabianpi:8080/basicui/app
It runs chrome in a container
Expected Behavior
Basic UI should work flawless with an openHAB environment that has a basic auth protection.
Current Behavior
BasicUI window opens but shows a blank tab.
Possible Solution
No known solution yet
Steps to Reproduce (for Bugs)
Context
Debugger notice:
Community reference: https://community.openhab.org/t/visual-studio-code-error-connecting-to-server-integrated-basic-ui/84277
Your Environment