Commit Graph

353 Commits (6921583410de3d5797a022ef5c8bcdc23ba12013)

Author SHA1 Message Date
Franck Nijhof 91180923ae
Fix HTTP 404 being logged as a stack trace (#75861) 2022-07-28 16:43:32 +02:00
Marc Mueller af7df260a0
Fix small type issues [core] (#75760) 2022-07-26 16:28:22 +02:00
Marc Mueller b1ed1543c8
Improve http decorator typing (#75541) 2022-07-21 13:07:42 +02:00
Franck Nijhof 9a4a7e2f4d
Extend failed login message with the request URL (#75218) 2022-07-14 21:43:14 +02:00
epenet 16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
J. Nick Koston 0c29b68cf8
Switch linear search to a dict lookup for ip bans (#74482) 2022-07-07 10:57:44 +02:00
J. Nick Koston 332cf3cd2d
Resolve and caches paths for CachingStaticResource in the executor (#74474) 2022-07-06 13:49:48 -05:00
J. Nick Koston 8dfb0cb4e7
Fix SIGN_QUERY_PARAM in check in auth_middleware (#74479) 2022-07-05 21:09:33 -07:00
J. Nick Koston 8b067e83f7
Initial orjson support take 3 (#73849)
* Initial orjson support take 2

Still need to work out problem building wheels

--

Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (comment)

This implements orjson where we use our default encoder.  This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently.  If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).

Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)

Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups).  I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes

If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`

Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">

* use for views as well

* handle UnicodeEncodeError

* tweak

* DRY

* DRY

* not needed

* fix tests

* Update tests/components/http/test_view.py

* Update tests/components/http/test_view.py

* black

* templates
2022-06-22 21:59:51 +02:00
Christopher Bailey 0461ec1566
Fix auth_sign_path with query params (take 2) (#73829) 2022-06-22 10:09:21 -05:00
J. Nick Koston 1e0a3246f4
Revert "Fix auth_sign_path with query params (#73240)" (#73808) 2022-06-21 22:45:16 -05:00
Christopher Bailey 67618311fa
Fix auth_sign_path with query params (#73240)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-21 14:21:47 -05:00
Franck Nijhof 5f44d0f8f9
Clean up accessing storage.Store helper via hass (#72009) 2022-05-17 18:45:57 +02:00
Marc Mueller 93cbb331e5
Update Mypy to 0.950 (#70948)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-04-27 20:49:54 -05:00
Marc Mueller 53245c6523
Update pylint to 2.13.0 (#68656) 2022-03-25 15:14:48 -07:00
Franck Nijhof 3afadf8adb
Revert "Block peer certs on supervisor" (#67104) 2022-02-23 12:32:07 +01:00
Paulus Schoutsen 938b64081b
Block peer certs on supervisor (#66837)
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
2022-02-22 13:59:40 -08:00
J. Nick Koston 3bf2be1765
Startup with an emergency self signed cert if the ssl certificate cannot be loaded (#66707) 2022-02-18 16:08:26 -08:00
Marc Mueller 370832f527
Fix http typing (#66506) 2022-02-14 13:40:31 +01:00
Franck Nijhof fa09cf663e
Update black to 22.1.0 (#65788) 2022-02-05 14:19:37 +01:00
Paulus Schoutsen 63f8e437ed
Add Home Assistant Content user (#64337) 2022-01-21 10:06:39 -08:00
epenet 6f631c542c
Import hassio (#64561)
* Import hassio

* Fix HassioAPIError

* Use relative import

* Adjust import

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-20 19:03:26 +01:00
Erik Montnemery 2eab3c8de1
Import persistent notification (part 3) (#63900) 2022-01-11 09:51:16 -08:00
epenet 40e77e2af0
Fix type hint in http register_view (#63385)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-04 21:25:16 -08:00
Tobias Sauerwein 2c904c0974
Bump mypy to 0.930 (#62642)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-12-27 17:55:17 +01:00
Paulus Schoutsen 914f7f85ec
Add local only users (#57598) 2021-11-29 14:01:03 -08:00
Simone Chemelli 5fc51130ea
Replace util.get_local_ip in favor of components.network.async_get_source_ip() - part 4 (#58669)
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-11-15 09:18:57 -08:00
Paulus Schoutsen 6ef64f6b1c
Fix CORS error in emulated_hue (#59570) 2021-11-11 22:11:41 -08:00
Bram Kragten 28c07f5c43
Fix CORS (#59360)
* Fix CORS

* rename

* Update view.py
2021-11-09 18:30:51 +01:00
Marc Mueller 4c68662612
Use assignment expressions 34 (#58823) 2021-10-31 19:01:16 +01:00
Ville Skyttä b52c5c82b1
Use http.HTTPStatus in components/[gh]* (#58246) 2021-10-23 20:34:53 +02:00
Marc Mueller aa7dc78a1e
Use assignment expressions 11 (#57792) 2021-10-17 20:15:48 +02:00
Ville Skyttä cc97502a0c
Use HTTPStatus instead of HTTP_* consts in aiohttp web response statuses (#56541) 2021-10-01 09:27:44 -07:00
Marc Mueller 565a9fea6b
Import Callable from collections.abc (2) (#56776) 2021-09-29 14:06:51 +02:00
Ville Skyttä d8d34fdd3b
Prefer HTTPStatus over int in HA view JSON functions (#56504)
* Prefer HTTPStatus over int in HA view JSON functions

* Update zwave tests to not expect a fixed typo
2021-09-22 21:59:52 +03:00
Ruslan Sayfutdinov 7195b8222b
Bump PyJWT to 2.1.0 (#55911) 2021-09-07 20:59:02 -07:00
Paulus Schoutsen 27e29b714c
Bump cloud to 0.47.1 (#55312)
* Bump cloud to 0.47.0

* Bump reqs

* Bump to 0.47.1

* Do not load hass_nabucasa during http startup

* fix some tests

* Fix test

Co-authored-by: Ludeeus <ludeeus@ludeeus.dev>
2021-09-01 09:54:54 -07:00
Ville Skyttä 59809503d1
Various type hint related improvements (#54971)
* Avoid some implicit generic Anys

* Fix hassio discovery view type hints

* Fix http view result type in assert message
2021-08-21 13:58:49 +02:00
Paulus Schoutsen bab7d46c9b
Guard partial upgrade (#54617) 2021-08-15 19:56:56 -07:00
Paulus Schoutsen 38a7bdbcf3
Do not process forwarded for headers for cloud requests (#54364) 2021-08-10 01:45:56 +02:00
Marc Mueller 10bfc78365
Fix missing encoding with open() (#53593)
* Fix missing encoding with open()

* Fix tests

* Improve open - frontend
2021-07-28 09:41:45 +02:00
Joakim Plate d339e3bd8c
Reject trusted network access from proxies (#52388) 2021-07-02 11:49:42 +02:00
Joakim Plate eedf1c3ebe
Reject requests from the proxy itself (#52073)
* Reject requests from the proxy itself

* Adjust tests
2021-06-27 19:02:51 +02:00
Franck Nijhof 33e08f38da
Raise bad request when receiving HTTP request from untrusted proxy (#51839)
* Raise bad request when receiving HTTP request from untrusted proxy

* Fix code comment
2021-06-17 04:41:19 +02:00
Franck Nijhof cdd1f6b2f0
Always load middle to handle forwarded proxy data (#51332) 2021-06-01 09:38:55 -07:00
Paulus Schoutsen bd0373388d
Trusted networks auth provider warns if detects a requests with x-forwarded-for header while the http integration is not configured for reverse proxies (#51319)
* Trusted networks auth provider to require http integration configured for proxies to allow logging in with requests with x-forwarded-for header

* Make it a warning
2021-06-01 12:51:44 +02:00
Ruslan Sayfutdinov ce15f28642
Add missing type hints in http component (#50411) 2021-05-10 14:30:47 -07:00
J. Nick Koston a4432557d3
Defer writing http config until after startup has calmed down (#50000) 2021-05-02 19:48:49 -10:00
Marc Mueller c07646db5d
Update typing syntax (#49480)
* Update typing syntax

* Replace typing imports with ones from collections where possible

* Changes after review
2021-04-20 17:40:41 +02:00
Franck Nijhof 055cdc64c0
Add support for IoT class in manifest (#46935) 2021-04-15 10:21:38 +02:00