Marc Mueller
87bb7ced79
Use PEP 695 for simple type aliases ( #117633 )
2024-05-17 14:42:21 +02:00
Marc Mueller
8f614fb06d
Use HassKey for helpers (2) ( #117013 )
2024-05-07 11:24:13 -05: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
Robert Resch
348e1df949
Add strict connection ( #112387 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-12 14:47:46 +02:00
Sid
9cbed10372
Enable Ruff PYI041 ( #115229 )
2024-04-08 09:29:05 -10:00
Marc Mueller
a0e6fd6ec5
Add improved typing for event fire and listen methods ( #114906 )
...
* Add EventType implementation
* Update integrations for EventType
* Change state_changed to EventType
* Fix tests
* Remove runtime impact
* Add tests
* Move to stub file
* Apply pre-commit to stub files
* Fix ruff PYI checks
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-07 13:28:24 -10:00
Sid
8e98ba7312
Add first batch of Ruff PYI rules ( #115100 )
...
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-04-07 11:30:50 -10:00
J. Nick Koston
32004973c8
Simplify invalidating the User cache ( #115074 )
2024-04-07 12:17:18 +02:00
Marc Mueller
816ce116bf
Remove unnecessary functools.cached_property backport ( #114239 )
2024-04-04 11:24:26 +02:00
J. Nick Koston
4341b21a61
Migrate auth to use async_import_module to avoid blocking I/O in the event loop ( #113387 )
2024-03-14 10:44:36 +01:00
Joost Lekkerkerker
05172d8e4d
Improve loops and lists ( #113269 )
...
* Enable PERF
* Enable PERF rule
* Enable PERF rule
* Don't enable flag yet
2024-03-14 10:22:20 +01: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
aa16a9d707
Add empty line after module docstring (3) ( #112750 )
2024-03-08 20:38:34 +01:00
Marc Mueller
19ab3d6daf
Add empty line after module docstring [helpers + other] ( #112707 )
2024-03-08 10:36:11 -05:00
Erik Montnemery
82efb3d35b
Make FlowResult a generic type ( #111952 )
2024-03-07 12:41:14 +01:00
Erik Montnemery
3d3e9900c3
Add TypeVar default for FlowResult ( #112345 )
...
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2024-03-05 22:52:11 +01:00
Erik Montnemery
a0e558c457
Add generic classes BaseFlowHandler and BaseFlowManager ( #111814 )
...
* Add generic classes BaseFlowHandler and BaseFlowManager
* Migrate zwave_js
* Update tests
* Update tests
* Address review comments
2024-02-29 16:52:39 +01:00
Michael
bb8828c86f
Address late review on auth ( #108852 )
2024-01-25 18:15:35 +01: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
7c86ab14c3
Refactor service enumeration methods to better match existing use cases ( #108671 )
2024-01-22 14:21:17 -10:00
J. Nick Koston
740209912c
Small performance improvements to handing revoke token callbacks ( #108625 )
...
- Use a set to avoid linear search for remove
- Avoid recreating the unregister function each time
2024-01-21 22:49:06 -05: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
Aarni Koskela
706add4a57
Switch formatting from black to ruff-format ( #102893 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Robert Resch
cf9b0e804f
Deprecate legacy api auth provider ( #104409 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:16:18 +01:00
Robert Resch
852fb58ca8
Extend `auth/providers` endpoint and add `/api/person/list` endpoint for local ip requests ( #103906 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-11-24 17:11:54 +01:00
Hejki
65a2f5bcd5
Support for group into command_line auth provider ( #92906 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-24 13:19:25 +01:00
J. Nick Koston
1a6184a9aa
Allow non-admins to subscribe to the issue registry updated event ( #103145 )
2023-10-31 16:29:22 -05:00
J. Nick Koston
93f10cdce8
Move event permissions out of the websocket api into auth ( #101975 )
2023-10-15 23:14:19 +02:00
J. Nick Koston
2dfc8b9d7f
Avoid conversion of timestamps in jwt auth ( #101856 )
2023-10-13 14:11:17 +02:00
Marc Mueller
0b2b486754
Update mypy to 1.6.0 ( #101780 )
2023-10-11 13:25:11 +02:00
Franck Nijhof
c3936e6f14
Replace isort with ruff ( #94302 )
2023-06-08 23:43:56 +02:00
Patrick Li
46103f56c4
Fix trusted_users group schema ( #92847 )
...
* Fix trusted_users group schema
* Add tests for CONFIG_SCHEMA
2023-05-23 20:11:25 +02:00
J. Nick Koston
32b70ea133
Bump PyJWT to 2.7.0 ( #93128 )
2023-05-16 10:26:04 +02:00
J. Nick Koston
ca576d45ac
Cache decode of JWT tokens ( #90013 )
2023-03-22 16:03:41 -10:00
epenet
f2b736fad0
Adjust entity registry access in core platforms ( #88944 )
...
* Adjust entity registry access in platforms
* Adjust more core components
2023-03-01 08:02:16 +01:00
J. Nick Koston
03eea7bd3f
Avoid subprocess memory copy when c library supports posix_spawn ( #87958 )
...
* use posix spawn on alpine
* Avoid subprocess memory copy when c library supports posix_spawn
By default python 3.10 will use the fork() which has to
copy all the memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided.
In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14
The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)
The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn
* Avoid subprocess memory copy when c library supports posix_spawn
By default python 3.10 will use the fork() which has to
copy memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided and subprocess creation does not
get discernibly slow the larger the Home Assistant
python process grows.
In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14
The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)
The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn
* missed some
* adjust more tests
* coverage
2023-02-13 09:02:51 -05:00
Franck Nijhof
ca1a12898c
Enable Ruff D212 ( #87347 )
2023-02-03 23:08:48 +01:00
Marc Mueller
6397138589
Update Optional typing (1) [Py310] ( #86417 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-01-23 09:56:10 +01:00
Marc Mueller
8abce25948
Update Union typing (4) [Py310] ( #86427 )
2023-01-23 09:04:40 +01: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
Franck Nijhof
73a43bfd1d
Update pyotp to 2.8.0 ( #84339 )
2022-12-21 11:53:02 +01:00
Erik Montnemery
bf4c399b19
Improve data entry flow typing ( #84030 )
2022-12-15 12:41:20 +01:00
Erik Montnemery
22b4c445a0
Drop title from auth flows ( #83628 )
2022-12-12 10:53:28 +01:00
Aarni Koskela
8038485ca4
Use partition instead of split where possible in core ( #81806 )
2022-11-15 21:45:48 +01:00
Marc Mueller
0c8eeaa643
Update mypy to 0.990 ( #81783 )
...
* Update mypy to 0.990
* Remove type ignore - overriding attr with property (13475)
* Remove type ignores - hasattr (13544)
* Adjust type ignore - assignment (13549)
* New error code - type-abstract (13785)
* Disable annotation-unchecked (13851)
2022-11-08 14:41:39 +01:00