Cleanup API / old rebranding (#3623)

* Cleanup API / old rebranding

* cleanup p2

* next round

* better comments

* cleanup import

* support only installed add-ons

* legacy migration

* test fixes

* add old env back

* revert for Core

* fix issues with old core

* fix

* using installed short cat

* revert

* extend legacy

* cleanup

* fix path

* Fix missing

* add stop

* readd old token

* Add minimal

* extend attributes

* Add repo back

* add more repo info

* Make it working

* Bump frontend to e7848262 (#3680)

* Add icon

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
Pascal Vizeli
2022-06-21 15:19:04 +02:00
committed by GitHub
parent acfa686bb6
commit e92d8695c7
109 changed files with 242 additions and 398 deletions

View File

@@ -10,9 +10,6 @@ import voluptuous as vol
from voluptuous.humanize import humanize_error
from ..const import (
CONTENT_TYPE_BINARY,
HEADER_TOKEN,
HEADER_TOKEN_OLD,
JSON_DATA,
JSON_MESSAGE,
JSON_RESULT,
@@ -25,22 +22,20 @@ from ..exceptions import APIError, APIForbidden, DockerAPIError, HassioError
from ..utils import check_exception_chain, get_message_from_exception_chain
from ..utils.json import JSONEncoder
from ..utils.log_format import format_message
from .const import CONTENT_TYPE_BINARY, HEADER_TOKEN, HEADER_TOKEN_OLD
def excract_supervisor_token(request: web.Request) -> Optional[str]:
"""Extract Supervisor token from request."""
supervisor_token = request.headers.get(HEADER_TOKEN)
if supervisor_token:
if supervisor_token := request.headers.get(HEADER_TOKEN):
return supervisor_token
# Remove with old Supervisor fallback
supervisor_token = request.headers.get(HEADER_TOKEN_OLD)
if supervisor_token:
# Old Supervisor fallback
if supervisor_token := request.headers.get(HEADER_TOKEN_OLD):
return supervisor_token
# API access only
supervisor_token = request.headers.get(AUTHORIZATION)
if supervisor_token:
if supervisor_token := request.headers.get(AUTHORIZATION):
return supervisor_token.split(" ")[-1]
return None