mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Improve authentication handling for camera view (#75979)
This commit is contained in:
parent
1a8ccfeb56
commit
c795597511
@ -14,7 +14,7 @@ import os
|
|||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
from typing import Final, Optional, cast, final
|
from typing import Final, Optional, cast, final
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import hdrs, web
|
||||||
import async_timeout
|
import async_timeout
|
||||||
import attr
|
import attr
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -715,8 +715,11 @@ class CameraView(HomeAssistantView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
if request[KEY_AUTHENTICATED]:
|
# Attempt with invalid bearer token, raise unauthorized
|
||||||
|
# so ban middleware can handle it.
|
||||||
|
if hdrs.AUTHORIZATION in request.headers:
|
||||||
raise web.HTTPUnauthorized()
|
raise web.HTTPUnauthorized()
|
||||||
|
# Invalid sigAuth or camera access token
|
||||||
raise web.HTTPForbidden()
|
raise web.HTTPForbidden()
|
||||||
|
|
||||||
if not camera.is_on:
|
if not camera.is_on:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user