(
settings: Settings = Depends(get_server_settings),
authorization: Optional[str] = Depends(bearer_scheme),
)
| 239 | |
| 240 | |
| 241 | async def authenticate( |
| 242 | settings: Settings = Depends(get_server_settings), |
| 243 | authorization: Optional[str] = Depends(bearer_scheme), |
| 244 | ): |
| 245 | # Skip API key check if it's not set in settings |
| 246 | if settings.api_key is None: |
| 247 | return True |
| 248 | |
| 249 | # check bearer credentials against the api_key |
| 250 | if authorization and authorization.credentials == settings.api_key: |
| 251 | # api key is valid |
| 252 | return authorization.credentials |
| 253 | |
| 254 | # raise http error 401 |
| 255 | raise HTTPException( |
| 256 | status_code=status.HTTP_401_UNAUTHORIZED, |
| 257 | detail="Invalid API key", |
| 258 | ) |
| 259 | |
| 260 | |
| 261 | openai_v1_tag = "OpenAI V1" |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…