Commit Graph

53 Commits (2a127d19dd9def22c816261e536641550b5d9f80)

Author SHA1 Message Date
Joost Lekkerkerker 1fdd056c0e
Fix ruff manual-dict-comprehension PERF403 (#120723)
* Fix PERF403

* Fix

* Fix
2024-06-28 14:17:47 +02:00
Robert Resch 641507a45a
Add change username endpoint (#109057) 2024-06-24 18:51:19 +02:00
Robert Resch e087abe802
Add ws endpoint to remove expiration date from refresh tokens (#117546)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-29 09:09:59 +02:00
J. Nick Koston a57f4b8f42
Index auth token ids to avoid linear search (#116583)
* Index auth token ids to avoid linear search

* async_remove_refresh_token

* coverage
2024-05-05 16:47:26 -04:00
J. Nick Koston 76cd498c44
Replace utcnow().timestamp() with time.time() in auth_store (#116879)
utcnow().timestamp() is a slower way to get time.time()
2024-05-05 16:25:27 -04:00
J. Nick Koston 4882fed939
Avoid saving auth right after we load it during startup (#112008) 2024-03-09 11:03:22 -10:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
Michael f5d439799b
Add expiration of unused refresh tokens (#108428)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-01-24 13:24:22 -10:00
J. Nick Koston 2eea658fd8
Convert getting and removing access tokens to normal functions (#108670) 2024-01-22 20:51:33 -10:00
J. Nick Koston ec15b0def2
Always load auth storage at startup (#108543) 2024-01-20 16:16:43 -10:00
J. Nick Koston 3c6e7b188e
Remove OrderedDict from auth_store (#108546)
normal dicts keep track of insert order now so this should
no longer be needed
2024-01-20 20:36:43 -05:00
J. Nick Koston b1d0c6a4f1
Refactor User attribute caching to be safer and more efficient (#96723)
* Cache construction of is_admin

This has to be checked for a lot of api calls and the websocket
every time the call is made

* Cache construction of is_admin

This has to be checked for a lot of api calls and the websocket
every time the call is made

* Cache construction of is_admin

This has to be checked for a lot of api calls and the websocket
every time the call is made

* modernize

* coverage

* coverage

* verify caching

* verify caching

* fix type

* fix mocking
2024-01-13 15:10:50 -05:00
Franck Nijhof 64c2340fab
Core code styling improvements (#85963) 2023-01-15 23:00:51 +01:00
Franck Nijhof b0cee0bc46
String formatting and max line length - Part 1 (#84390)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-12-22 10:12:50 +01:00
epenet 16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
Franck Nijhof 5f44d0f8f9
Clean up accessing storage.Store helper via hass (#72009) 2022-05-17 18:45:57 +02:00
Franck Nijhof 69cc6ab5f1
Clean up accessing entity_registry.async_get_registry helper via hass (#72005) 2022-05-17 16:40:45 +02:00
Marc Mueller 240c9979c7
Move `disallow-any-generics` to mypy.ini (#63917) 2022-01-11 13:33:25 -08:00
Marc Mueller 021debb5c5
Resolve implicit imports (#63832) 2022-01-10 17:10:46 +01:00
Ruslan Sayfutdinov 55f4962c06
Fix pylint plugin which checks relative imports (#62693) 2021-12-23 11:14:47 -08:00
Paulus Schoutsen 914f7f85ec
Add local only users (#57598) 2021-11-29 14:01:03 -08:00
J. Nick Koston 96f7b0d910
Use atomicwrites for mission critical core files (#59606) 2021-11-15 11:19:31 +01:00
Marc Mueller 7af67d34cf
Use assignment expressions 01 (#56394) 2021-09-18 13:31:35 -10:00
Ville Skyttä 848c0be58a
Avoid some implicit generic Anys (#54577) 2021-08-16 23:12:06 +02:00
Marc Mueller fabd73f08b
Update typing 03 (#48015) 2021-03-17 21:46:07 +01:00
Joakim Plate 38d2cacf7a
Support blocking trusted network from new ip (#44630)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-01-28 12:06:20 +01:00
Bas Nijholt 67c56c860d Sort imports according to PEP8 for 'homeassistant' folder (#29789)
Components are already done
2019-12-09 16:42:10 +01:00
Franck Nijhof 2f0eb07624 Migrate legacy typehints in core to PEP-526 (#26403)
* Migrate legacy typehints in core to PEP-526

* Fix one type
2019-09-03 20:36:04 -07:00
Franck Nijhof decf13b948 Use literal string interpolation in core (f-strings) (#26166) 2019-08-23 09:53:33 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Ville Skyttä a6eef22fbc
Upgrade mypy to 0.710 (#24666)
* Upgrade mypy to 0.710

* Address mypy 0.710 errors
2019-06-22 10:19:36 +03:00
Paulus Schoutsen 4f5446ff02
Add area permission check (#21835) 2019-03-11 11:02:37 -07:00
Paulus Schoutsen 5b2c6648fb
Add user group (#21832)
* Add user group

* Rename system group to plural
2019-03-09 20:07:29 -08:00
Jason Hu 3d8673dbf8 Resolve auth_store loading race condition (#21794)
* Add lock in auth_store._async_load()

* Python 3.5 does not like assert_called_once()
2019-03-08 14:50:24 -08:00
Paulus Schoutsen 3928d034a3 Allow checking entity permissions based on devices (#19007)
* Allow checking entity permissions based on devices

* Fix tests
2018-12-05 11:41:00 +01:00
Paulus Schoutsen 28215d7edd
Make auth backwards compat again (#18792)
* Made auth not backwards compat

* Fix tests
2018-11-29 22:26:19 +01:00
Paulus Schoutsen 8b8629a5f4 Add permission checks to Rest API (#18639)
* Add permission checks to Rest API

* Clean up unnecessary method

* Remove all the tuple stuff from entity check

* Simplify perms

* Correct param name for owner permission

* Hass.io make/update user to be admin

* Types
2018-11-25 18:04:48 +01:00
Paulus Schoutsen 36c31a6293
Add permissions check in service helper (#18596)
* Add permissions check in service helper

* Lint

* Fix tests

* Lint

* Typing

* Fix unused impoert
2018-11-21 12:26:08 +01:00
Paulus Schoutsen f7f0a4e811
System groups (#18303)
* Add read only and admin policies

* Migrate to 2 system groups

* Add system groups

* Add system groups admin & read only

* Dont' mutate parameters

* Fix types
2018-11-08 12:57:00 +01:00
Paulus Schoutsen 61f7a39748
Add permissions foundation (#16890)
* Add permission foundation

* Address comments

* typing

* False > True

* Convert more lambdas

* Use constants

* Remove support for False

* Fix only allow True
2018-10-11 19:24:25 +02:00
Paulus Schoutsen c3b1121d77
Add group foundation (#16935)
Add group foundation
2018-10-08 16:35:38 +02:00
Paulus Schoutsen a559c06d6b
Make it easier for auth to consume newer formats (#17127) 2018-10-04 10:41:13 +02:00
Nicko van Someren e5861241c7 Added support for private storage. (#16878)
* Addded support for private storage.

Include 'private' flag parameters to the Store class and save_json function.
Updated various authentication and onboarding classes to use private stores.
Fixed unit test for emulated_hue which used a mock patch on save_json().

* Fixed Hound formatting issues not detected by local linting.
2018-09-26 10:24:32 +02:00
Jason Hu ff78a5b04b Track refresh token last usage information (#16408)
* Extend refresh_token to support last_used_at and last_used_by

* Address code review comment

* Remove unused code

* Add it to websocket response

* Fix typing
2018-09-12 13:24:16 +02:00
Paulus Schoutsen 4e3faf6108
Fix typo (#16556) 2018-09-11 12:55:05 +02:00
Jason Hu 9583947012 Long-lived access token (#16453)
* Allow create refresh_token with specific access_token_expiration

* Add token_type, client_name and client_icon

* Add unit test

* Add websocket API to create long-lived access token

* Allow URL use as client_id for long-lived access token

* Remove mutate_refresh_token method

* Use client name as id for long_lived_access_token type refresh token

* Minor change

* Do not allow duplicate client name

* Update docstring

* Remove unnecessary `list`
2018-09-11 12:05:15 +02:00
Paulus Schoutsen cdb8361050 Add support for revoking refresh tokens (#16095)
* Add support for revoking refresh tokens

* Lint

* Split revoke logic in own method

* Simplify

* Update docs
2018-08-21 11:02:55 -07:00
Paulus Schoutsen 2ad0bd4036
Split out storage delay save (#16017)
* Split out storage delayed write

* Update code using delayed save

* Fix tests

* Fix typing test

* Add callback decorator
2018-08-17 20:18:21 +02:00
Ville Skyttä 649f17fe47 Add type hints to homeassistant.auth (#15853)
* Always load users in auth store before use

* Use namedtuple instead of dict for user meta

* Ignore auth store tokens with invalid created_at

* Add type hints to homeassistant.auth
2018-08-16 22:25:41 +02:00
Paulus Schoutsen e776f88eec
Use JWT for access tokens (#15972)
* Use JWT for access tokens

* Update requirements

* Improvements
2018-08-14 21:14:12 +02:00