mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-02-03 14:21:38 -08:00
DO NOT DO THIS AT HOME
This commit is contained in:
parent
de497acd69
commit
82b3eea1fd
2 changed files with 8 additions and 2 deletions
|
|
@ -2,7 +2,9 @@ import base64
|
|||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.responses import Response
|
||||
from fastapi import FastAPI
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
class BasicAuthMiddleware(BaseHTTPMiddleware):
|
||||
def __init__(self, app, username: str, password: str):
|
||||
super().__init__(app)
|
||||
|
|
@ -11,6 +13,7 @@ class BasicAuthMiddleware(BaseHTTPMiddleware):
|
|||
|
||||
async def dispatch(self, request, call_next):
|
||||
# Extract the Authorization header
|
||||
logger.warning(f"{request.headers}")
|
||||
auth_header = request.headers.get("Authorization")
|
||||
if not auth_header or not auth_header.startswith("Basic "):
|
||||
return self._unauthorized_response()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue