Fix auth middleware: use insert(0) on FrozenList before app starts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -120,15 +120,10 @@ def main():
|
||||
public_url=public_url,
|
||||
)
|
||||
|
||||
# Add HTTP Basic Auth middleware if API key is configured
|
||||
# Add HTTP Basic Auth if API key is configured
|
||||
if web_key:
|
||||
_orig_make_app = server._make_app
|
||||
|
||||
async def _authed_make_app():
|
||||
app = await _orig_make_app()
|
||||
|
||||
@aio_web.middleware
|
||||
async def basic_auth(request, handler):
|
||||
async def basic_auth_middleware(request, handler):
|
||||
auth_header = request.headers.get("Authorization", "")
|
||||
if auth_header.startswith("Basic "):
|
||||
try:
|
||||
@@ -147,7 +142,11 @@ def main():
|
||||
text="Authentication required",
|
||||
)
|
||||
|
||||
app.middlewares.insert(0, basic_auth)
|
||||
_orig_make_app = server._make_app
|
||||
|
||||
async def _authed_make_app():
|
||||
app = await _orig_make_app()
|
||||
app.middlewares.insert(0, basic_auth_middleware)
|
||||
return app
|
||||
|
||||
server._make_app = _authed_make_app
|
||||
|
||||
Reference in New Issue
Block a user