fix: add X-OPENHAB-AUTH-HEADER cookie to prevent login conflict with …#802
Open
riccardo-casazza wants to merge 1 commit into
Open
fix: add X-OPENHAB-AUTH-HEADER cookie to prevent login conflict with …#802riccardo-casazza wants to merge 1 commit into
riccardo-casazza wants to merge 1 commit into
Conversation
…openHAB 3+ When using nginx basic auth in front of openHAB 3+, two authentication layers end up competing for the same HTTP Authorization header: nginx sets it to "Basic ..." and openHAB sets it to "Bearer ..." after login. This causes the openHAB login to fail when basic auth is enabled on the reverse proxy. Adding the X-OPENHAB-AUTH-HEADER cookie instructs the openHAB UI to use the X-OPENHAB-TOKEN header instead of Authorization for its own token, resolving the conflict and allowing both nginx basic auth and openHAB authentication to coexist correctly. Reference: https://community.openhab.org/t/oh3-with-nginx-reverse-proxy-and-authentication/106528
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
X-OPENHAB-AUTH-HEADERcookie to the openHAB nginx reverse proxyconfiguration. When nginx basic auth is enabled, both nginx and openHAB 3+
compete for the HTTP
Authorizationheader — nginx sets it toBasic ...while openHAB sets it to
Bearer ...after login. This causes openHABauthentication to fail silently when accessed through the proxy.
The fix instructs the openHAB UI to use the alternative
X-OPENHAB-TOKENheader for its own token instead of
Authorization, allowing bothauthentication layers to coexist without conflict.
Benefits of this PR and context
Without this fix, users who enable nginx basic auth on top of openHAB 3+
experience a broken login flow: the openHAB login page appears to accept
credentials but immediately fails, requiring the user to dismiss the nginx
auth popup and re-authenticate through openHAB's own login screen. This
is a known issue affecting all openHAB 3+ installations behind a nginx
reverse proxy with basic auth enabled.
This one-line addition makes the sample configuration work correctly
out of the box for openHAB 3+ without affecting openHAB 2.x compatibility.
How Has This Been Tested?
Tested on a personal homelab running:
configuration
.htpasswdVerified that after adding the cookie header:
Source / References
Schaus): https://community.openhab.org/t/oh3-with-nginx-reverse-proxy-and-authentication/106528