Skip to content

Added WS endpoint for changing homeassistant password.#15527

Merged
balloob merged 5 commits intohome-assistant:devfrom
jeradM:change-pw
Jul 19, 2018
Merged

Added WS endpoint for changing homeassistant password.#15527
balloob merged 5 commits intohome-assistant:devfrom
jeradM:change-pw

Conversation

@jeradM
Copy link
Copy Markdown
Member

@jeradM jeradM commented Jul 18, 2018

Description:

Adds websocket endpoint to allow changing a user's password using the homeassistant auth_provider.

Related frontend PR: home-assistant/frontend#1464

Checklist:

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

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

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

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Looks good! Will require tests

provider = _get_provider(hass)
await provider.async_initialize()

user = connection.request.get('hass_user')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Want to do user check first

username = None
for credential in user.credentials:
if credential.auth_provider_type == provider.type:
username = credential.data['username']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a break

# Can happen if somehow we didn't clean up a credential
pass

async def async_change_password(self, username, new_password):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for this, just call straight the data object

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Still use executor for password hashing though right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes

WS_TYPE_CHANGE_PASSWORD = 'config/auth_provider/homeassistant/change_password'
SCHEMA_WS_CHANGE_PASSWORD = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
vol.Required('type'): WS_TYPE_CHANGE_PASSWORD,
vol.Required('current_password'): str,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You misunderstood. I think that this is great 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh oops 🤦‍♂️ I'll add it back

@jeradM jeradM changed the title WIP: Added WS endpoint for changing homeassistant password. Added WS endpoint for changing homeassistant password. Jul 19, 2018
@ghost ghost assigned balloob Jul 19, 2018
@balloob balloob merged commit 396895d into home-assistant:dev Jul 19, 2018
@ghost ghost removed the in progress label Jul 19, 2018
@balloob balloob added this to the 0.74 milestone Jul 19, 2018
balloob pushed a commit that referenced this pull request Jul 19, 2018
* Added WS endpoint for changing homeassistant password.

* Remove change password helper. Don't require current password.

* Restore current password verification.

* Added tests.

* Use correct send method
@balloob balloob mentioned this pull request Jul 20, 2018
michaeldavie pushed a commit to michaeldavie/home-assistant that referenced this pull request Jul 31, 2018
…t#15527)

* Added WS endpoint for changing homeassistant password.

* Remove change password helper. Don't require current password.

* Restore current password verification.

* Added tests.

* Use correct send method
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
…t#15527)

* Added WS endpoint for changing homeassistant password.

* Remove change password helper. Don't require current password.

* Restore current password verification.

* Added tests.

* Use correct send method
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants