mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-20 13:54:36 +01:00
Add ability to specify separator used in proxy headers (#18336)
This commit is contained in:
@@ -202,9 +202,15 @@ async def get_current_user(request: Request):
|
||||
|
||||
def require_role(required_roles: List[str]):
|
||||
async def role_checker(request: Request):
|
||||
proxy_config: ProxyConfig = request.app.frigate_config.proxy
|
||||
|
||||
# Get role from header (could be comma-separated)
|
||||
role_header = request.headers.get("remote-role")
|
||||
roles = [r.strip() for r in role_header.split(",")] if role_header else []
|
||||
roles = (
|
||||
[r.strip() for r in role_header.split(proxy_config.separator)]
|
||||
if role_header
|
||||
else []
|
||||
)
|
||||
|
||||
# Check if we have any roles
|
||||
if not roles:
|
||||
@@ -269,7 +275,8 @@ def auth(request: Request):
|
||||
# if comma-separated with "admin", use "admin", else use default role
|
||||
success_response.headers["remote-role"] = (
|
||||
"admin"
|
||||
if role and "admin" in [r.strip() for r in role.split(",")]
|
||||
if role
|
||||
and "admin" in [r.strip() for r in role.split(proxy_config.separator)]
|
||||
else proxy_config.default_role
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user