mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-12 03:36:31 +00:00
Add support for long live token (#719)
* Add support for long live token * Update proxy.py
This commit is contained in:
parent
61eefea358
commit
4a9dcb540e
@ -7,7 +7,7 @@ import aiohttp
|
|||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import (
|
from aiohttp.web_exceptions import (
|
||||||
HTTPBadGateway, HTTPInternalServerError, HTTPUnauthorized)
|
HTTPBadGateway, HTTPInternalServerError, HTTPUnauthorized)
|
||||||
from aiohttp.hdrs import CONTENT_TYPE
|
from aiohttp.hdrs import CONTENT_TYPE, AUTHORIZATION
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
|
||||||
from ..const import HEADER_HA_ACCESS
|
from ..const import HEADER_HA_ACCESS
|
||||||
@ -22,9 +22,13 @@ class APIProxy(CoreSysAttributes):
|
|||||||
|
|
||||||
def _check_access(self, request):
|
def _check_access(self, request):
|
||||||
"""Check the Hass.io token."""
|
"""Check the Hass.io token."""
|
||||||
hassio_token = request.headers.get(HEADER_HA_ACCESS)
|
if AUTHORIZATION in request.headers:
|
||||||
addon = self.sys_addons.from_token(hassio_token)
|
bearer = request.headers[AUTHORIZATION]
|
||||||
|
hassio_token = bearer.split(' ')[-1]
|
||||||
|
else:
|
||||||
|
hassio_token = request.headers.get(HEADER_HA_ACCESS)
|
||||||
|
|
||||||
|
addon = self.sys_addons.from_token(hassio_token)
|
||||||
if not addon:
|
if not addon:
|
||||||
_LOGGER.warning("Unknown Home Assistant API access!")
|
_LOGGER.warning("Unknown Home Assistant API access!")
|
||||||
elif not addon.access_homeassistant_api:
|
elif not addon.access_homeassistant_api:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user