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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auth by default 馃檲 #16107

Merged
merged 4 commits into from Aug 23, 2018
Merged

Enable auth by default 馃檲 #16107

merged 4 commits into from Aug 23, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Aug 21, 2018

Description:

This enabled the new authentication system by default. This will enable both the Home Assistant local auth provider and the Legacy API password auth provider. New users will be routed via an onboarding flow on initial boot to create a new user. This new user will be owner and is able to add more users.

Breaking change: It is no longer possible to use Home Assistant without authentication. To allow users to log in without entering a username or password, you can configure the trusted networks auth provider. If you were using another application to provide authentication, like NGINX, configure it to set the header x-ha-access: <API PASSWORD> on each request. In the future, this header will be replaced with a header containing a long lived access token (#15195).

(I don't use these platforms like NGINX, would be nice if people would contribute config examples)

Related issue (if applicable): #15703

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@balloob balloob requested a review from a team as a code owner August 21, 2018 15:29
@homeassistant homeassistant added core small-pr PRs with less than 30 lines. cla-signed labels Aug 21, 2018
@ghost ghost assigned balloob Aug 21, 2018
@ghost ghost added the in progress label Aug 21, 2018
@awarecan
Copy link
Contributor

awarecan commented Aug 21, 2018

To allow users to log in with entering a username or password, you can use the trusted networks auth provider.

Sounds not right.

To allow users to log in without entering password, you can use the trusted networks auth provider.

Example configuration for trusted networks auth provider:

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: legacy_api_password
    - type: trusted_networks

http:
  trusted_networks:
    - 127.0.0.1
    - ::1
    - 192.168.0.0/24

@balloob
Copy link
Member Author

balloob commented Aug 21, 2018

My bad, that didn't sound right. I am going to add some docs . Will add the config example there.

@awarecan
Copy link
Contributor

Another thought, if user doesn't set api_password, we should either not load leagcy_api_password auth provider, or let it failed quietly.

@balloob
Copy link
Member Author

balloob commented Aug 22, 2018

@awarecan good point, I will open a PR.

@pvizeli
Copy link
Member

pvizeli commented Aug 22, 2018

or let it failed quietly

Not load with a error is better. Fails is a bit hard for docker user.

@balloob
Copy link
Member Author

balloob commented Aug 22, 2018

I have a better idea, cooking up a PR :)

@balloob
Copy link
Member Author

balloob commented Aug 22, 2018

Legacy API password provider will now abort any login flow if API password has not been set: #16127

@awarecan
Copy link
Contributor

So the new user will see two auth providers, and the legacy one is broken out-of-box?

@balloob
Copy link
Member Author

balloob commented Aug 22, 2018

They will see an abort message saying that it won't work because there is no HTTP password. They already created an owner via onboarding, so they can log in with that.

@pvizeli
Copy link
Member

pvizeli commented Aug 22, 2018

Why we need legacy_api_password in default config? If they not working out of the box we need it not inside default config because user need change config manual and if they need change the config, they could also set the legacy_api_password?

@awarecan
Copy link
Contributor

I think we should auto load legacy_api_pasword depends on if http.api_password exist

@balloob
Copy link
Member Author

balloob commented Aug 23, 2018

I like that idea.

@balloob
Copy link
Member Author

balloob commented Aug 23, 2018

Updated.

@@ -87,9 +87,11 @@ def from_config_dict(config: Dict[str, Any],
log_no_color)

core_config = config.get(core.DOMAIN, {})
has_api_password = bool((config.get('http') or {}).get('api_password'))
Copy link
Member Author

Choose a reason for hiding this comment

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

If a user has just http: in their config, the key exists but is None. The or solves both if key does not exist or when it's None.

@balloob
Copy link
Member Author

balloob commented Aug 23, 2018

Pascal you were right, we should avoid to get people to configure auth themselves. The default settings should suffice. This is a good solution.

@balloob balloob merged commit d21d7ce into dev Aug 23, 2018
@ghost ghost removed the in progress label Aug 23, 2018
@balloob balloob deleted the enable-auth branch August 23, 2018 11:38
@balloob balloob mentioned this pull request Aug 29, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
* Enable auth by default

* Only default legacy_api_password if api_password set

* Tweak bool check

* typing
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants