openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
923 stars 424 forks source link

Android app not working in OH3 with reverse proxy #2038

Closed jti989 closed 3 years ago

jti989 commented 3 years ago

Hi,

I get a http401 error in the app when I try to connect to my openhab3 instance through a reverse proxy with the openhab authentication enabled.

Steps to reproduce:

  1. Set up openhab 3.0.0 (on docker in my case)
  2. set up a reverse proxy with basic auth enabled (traefik 2.3 in my case)
  3. install openhab app for android (2.15.15-beta in my case)
  4. configure the app with the adress of reverse proxy and auth of reverse proxy: url: openhab.reverseproxy.example.com user: user-of-reverse-proxy-auth password: password-of-reverse-proxy-auth

You will get an "Authentication failed" error in the app. The solution is to disable the openhab internal authentication with bundle:stop org.openhab.core.io.rest.auth. This has to be done after every restart of openhab and solves the app-issue, but as far as I noticed destroyes the admin view in the normal webinterface (mainUI).

Is there an option to disable auth from openhab completely and have the mainUI running? Like it was in 2.5?

jti989 commented 3 years ago

Found this link in one of the related topics:

https://community.openhab.org/t/oh3-with-nginx-reverse-proxy-and-authentication/106528/14

This helped me, here my configuration for traefik with kubernetesCRD:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: openhab
spec:
  headers:
    customResponseHeaders:
      Set-Cookie: "X-OPENHAB-AUTH-HEADER=1"
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: basic-auth
spec:
  basicAuth:
    secret: somesecret
    removeHeader: true