-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: protect endpoints with auth API key #127
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do we know if the calling side is also always using the KEY when it should?
@@ -8,7 +8,7 @@ | |||
from typing import List, Union, Generator, Iterator | |||
|
|||
|
|||
from utils.pipelines.auth import bearer_security, get_current_user | |||
from utils.pipelines.auth import get_current_user_or_abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should keep the get_current_user
convention. Please refer to our main Open WebUI repo!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Timothy, I'm sorry but I don't understand what you mean. Are you talking about adding the HTTP exception in the get_current_user
or implement something like the function get_current_user_by_api_key
(https://github.com/open-webui/open-webui/blob/eff736acd2e0bbbdd0eeca4cc209b216a1f23b6a/backend/utils/utils.py#L116C5-L116C32)?
@franciscovelez The following quick change basically ensured that API key is validated for the completion endpoint:
This doesn't meet your need? |
@jabbasj Of course this quick change solves the problem for that endpoint but I still think that we can take advantage of the injection system provided by FastAPI, create a function that performs those checks and reuse it (Don't Repeat Yourself principle). |
I've just noticed that some endpoints in this project are not protected, so any person with the URL can make calls to
/chat/completions
, for instance, without knowing the API key. I've created a new FastAPI dependency function that check if a valid API key has been provided (get_current_user_or_abort
) and added it to each endpoint.