mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-19 06:55:56 +08:00
Merge pull request #12433 from gaby/fix-allowed-endpoints
fix: API Key Endpoint Restrictions for Dynamic Paths
This commit is contained in:
commit
793aa307ef
@ -182,7 +182,11 @@ def get_current_user(
|
|||||||
).split(",")
|
).split(",")
|
||||||
]
|
]
|
||||||
|
|
||||||
if request.url.path not in allowed_paths:
|
# Check if the request path matches any allowed endpoint.
|
||||||
|
if not any(
|
||||||
|
request.url.path == allowed or request.url.path.startswith(allowed + "/")
|
||||||
|
for allowed in allowed_paths
|
||||||
|
):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.API_KEY_NOT_ALLOWED
|
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.API_KEY_NOT_ALLOWED
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user