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

Reset Authorization header on proxied request #2259

Conversation

bytespider
Copy link

@bytespider bytespider commented Nov 8, 2021

Home Assistant allows a much richer set of characters for username, however the Mosquitto auth plugin sends both Basic Auth and a URL encoded parameter string.

HA will parse the Basic Authentication header first and fail, while the later URL encoded string authorization will not.

In order to skip the more restrictive Basic Authentication check, I've updated the Nginx proxying to remove that header.

This fixes #2014

@bytespider
Copy link
Author

Is there anything more I need to do to get this reviewed?

@prosper86

This comment has been minimized.

@bytespider
Copy link
Author

@MartinHjelmare is anyone interested in this? I believe it's the correct solution as it brings the known behaviour from 5.x back into 6.x devices could no longer authenticate if they contained non-alphanumeric characters.

@@ -35,6 +35,7 @@ http {

location /authentication {
proxy_set_header X-Supervisor-Token "{{ env "SUPERVISOR_TOKEN" }}";
proxy_set_header Authorization "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, this will break HA authentication.

Copy link
Author

@bytespider bytespider Dec 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frenck can you please elaborate how?

As far as the code state when this was developed, the code checked first the Basic Auth, then the parameters that were passed in the URL.

HA uses Mosquitto Password and ACL files and doesn't authenticate via HTTP from this addon afaik.

Copy link
Author

@bytespider bytespider Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frenck wondering if you saw my reply to your last response?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bytespider I missed that indeed. Sorry about that.

and doesn't authenticate via HTTP from this addon afaik.

It does :) It authenticates against Home Assistant with Home Assistant user accounts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thank you.

I'll go through the code again as I clearly missed something. I thought I understood it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true. However Basic Auth only allows for a limited set of characters, whilst Mosquitto usernames and passwords are more diverse.

What would the impact of retiring Basic Auth from the Supervisor Auth API be?

I wonder if it's worth having the Auth Plugin control which method is sent to the backend HTTP server? @pvizeli thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the impact of retiring Basic Auth from the Supervisor Auth API be?

It is not about impact, it is about where this should be fixed. I feel like we are now working around a problem that shouldn't be "fixed" here, but on another place.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry perhaps I was unclear, I was suggesting that one option was perhapst that the Supervisory API no longer supports Basic Auth as a way or authorizing user credentials since it cannot handle the full set of characters supported by HA usernames and passwords.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting that one option was perhapst that the Supervisory API no longer supports Basic Auth

It was introduced as the last of all authentication handling and actually used by almost all add-ons.

So thinking about the specifications and limitations, this is about the colon : I guess.
I suggest ensuring we don't accept colons in usernames. Reason why: This is making it work for this special case, but that doesn't solve the case that Home Assistant currently allows for it (apparently) and the Supervisor can't handle it (apparently).

TL;DR; this PR works around an issue, and is not address or fixing the greater problem behind it. Therefore, I don't think this PR should be merged.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disappointing conclusion, but thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username with colon is NG in Mosquitto broker 6.0.0
5 participants