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

evcc in iFrame - cannot access restricted / protected area #13893

Closed
michiproep opened this issue May 13, 2024 · 19 comments · Fixed by #13896 or #14051
Closed

evcc in iFrame - cannot access restricted / protected area #13893

michiproep opened this issue May 13, 2024 · 19 comments · Fixed by #13896 or #14051
Labels
question Rather clarification than issue

Comments

@michiproep
Copy link
Sponsor

Describe the bug

When I show evcc within an iFrame - in my case within an iobroker vis - it is not possible to enter a password protected / restircted area.
After entering the password nothing happens. When you show evcc normal in the browser, everything works as expected.

Steps to reproduce

...

Configuration details

---

Log details

---

What type of operating system are you running?

Linux

Version

0.126.2

@andig
Copy link
Member

andig commented May 13, 2024

I would simply say that we‘re not supporting iframes. They are a thing from the past imho.

/cc @naltatis

@andig andig added the question Rather clarification than issue label May 13, 2024
@michiproep
Copy link
Sponsor Author

michiproep commented May 13, 2024

@andig : generally, I agree. But within home automation tools which usually run in Kiosk mode where you plug a bunch of different things within a common start page, this is the only way and still very common.

But when I think about it, it might not be a evcc bug... May-be, it's due to "browser vendors restricting cookies in iFrames". Not sure what evcc does with the password? Does it issue a session cookie?

@StefanSchoof
Copy link
Contributor

Are both (iobroker and evcc) via http or is one or both https?

@naltatis
Copy link
Member

@michiproep magst du mal nen Screenshot der Konsole in den Browser-Devtools posten? Mir ist bisher nicht ganz klar, was da schiefgeht. Ein erfolgreicher Login setzt ein http-only Cookie. Das sollte auch im iframe funktionieren. Gibt da aber in der Tat einiges an Security Settings, die sowohl die Host- und Inkludierte-Seite setzen kann.

@mdkeil
Copy link
Contributor

mdkeil commented May 14, 2024

Keine Ahnung, ob ich Äpfel mir Birnen vergleiche-- bei mir läuft evcc in HA in einer Website-Kachel (aber via https), da funktioniert die Auth ohne Probleme.. ich glaube, dass dort aber kein iframe genutzt wird.

@michiproep
Copy link
Sponsor Author

Neue Info: Scheint nur im Edge zu aufzutreten.
Und ja, bei mir läuft intern alles nur unter http.
Konsole zeigt das hier:
grafik

@naltatis
Copy link
Member

@michiproep Ok danke. Ich versuch das mal nachzustellen.

@michiproep
Copy link
Sponsor Author

michiproep commented May 14, 2024

Ich glaub, ich habs gefunden. Der Cookie Header hat kein SameSite Attribut.
Browser scheinen einen unterschiedlichen Default Wert zu verwenden.
In meinem Fall bräuchte ich "None", aber aus Security-Sicht sollte das wohl konfigurierbar sein...

Vielleicht im yaml ein "allowIFrame"?

@naltatis
Copy link
Member

Ich kann deinen Fall leider immer noch nicht reproduzieren. evcc in iFrame eingebettet im Edge funktioniert bei mir ohne Fehler. Für das Auth-Cookie ist aber Same-Site: strict eigentlich die saubere/sichere Lösung. Ich nehm das mal in den Master. Bitte teste mal morgen mit dem Nightly ob es dein Problem löst.

@michiproep
Copy link
Sponsor Author

ok. danke. Ich muss mir mal ein Testsystem für den nightly aufsetzen...
Aber mit "strict" erwarte ich eigentlich, dass es nirgends mehr funktioniert. Mal schauen...

@michiproep
Copy link
Sponsor Author

michiproep commented May 20, 2024

Hi @naltatis , wie erwartet funktioniert das mit "strict" jetzt nirgends (kein Browser) mehr...
Können wir nicht "strict" als default machen, aber im yaml überschreibbar machen?

@naltatis
Copy link
Member

Ok, hab mich jetzt mal ausführlicher mit dem "Iframe" Anwendungsfall beschäftigt. Generell verhalten sich die Browser da sehr unterschiedlich. Gerade was Cookies ohne SSL angeht. Ich habe jetzt mal die Same Site Policy gelockert und Unterstützung für CHIPS hinzugefügt (siehe PR), um nicht von Anti-Tracking-Maßnahmen getroffen zu werden. Für ein stabiles Setup, das in allen Browsern und auch zukünftig funktioniert, sollte der iframe Inhalt auf jeden Fall per HTTP ausgeliefert werden.

@naltatis
Copy link
Member

Ok, ist leider doch komplizierter. Siehe Kommentar im PR. @michiproep bindest du den iframe via https ein?

@naltatis naltatis reopened this May 22, 2024
@naltatis naltatis closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
@michiproep
Copy link
Sponsor Author

Ok, ist leider doch komplizierter. Siehe Kommentar im PR. @michiproep bindest du den iframe via https ein?

Nein, alles http

@StefanSchoof
Copy link
Contributor

@naltatis Wäre es eine Idee zu erkennen, ob evcc in Iframe läuft und wenn ja, an den Stellen wo das Passwort erforderlich ist, ein Link zum öffnen von evcc in einem neuen Tab anzubieten.

Das wäre für Nutzer bei denen es aktuell nicht klappt nicht optimal, aber ich Glaube wenn man als weniger technikaffine in das Problem läuft man Recht auf geschmissen ist.

@naltatis
Copy link
Member

@StefanSchoof bin mir noch nicht ganz sicher, wie man das gut erkennen kann. Aber das wäre in der Tat erstmal eine einfache Lösung. Wenn wir iframe + auth + http zuverlässig unterstützten wollen werden wir vmtl. weg vom Cookie auf JWT in LocalStorage gehen müssen :/

@michiproep
Copy link
Sponsor Author

Hi @naltatis,
bei läuft ja alles nur lokal (bzw via VPN). Ich bräuchte eigentlich gar keinen Schutz...
Ich wäre eigentlich dafür, dass man Auth komplett abschalten können sollte.
Aber fall es aktiv ist, dann solltest du schon auf ein httpOnly/strict Cookie bestehen (und eigentlich auch auf secure, was aber https bedingt)

@StefanSchoof
Copy link
Contributor

Laut Stack Overflow soll das mit

function inIframe () {
    try {
        return window.self !== window.top;
    } catch (e) {
        return true;
    }
}

gehen. https://stackoverflow.com/a/326076/4319676

@naltatis
Copy link
Member

Hier jetzt erstmal der vorgeschlagene Hinweis wenn Login erfolgreich war (richtiges Passwort) aber der Zustand nicht gehalten werden kann (Passwort). \cc @StefanSchoof

@naltatis naltatis reopened this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Rather clarification than issue
Projects
None yet
5 participants