Skip to content

Commit 998c8e8

Browse files
iAmir97AmirBalwel
andcommitted
[owl] Fix duplicate auth parameters in OpenAPI (#888)
* init Signed-off-by: AmirBalwel <amir.balwel@embeddedllm.com> * fix test Signed-off-by: AmirBalwel <amir.balwel@embeddedllm.com> * update Signed-off-by: AmirBalwel <amir.balwel@embeddedllm.com> * update a route where auth is optional to use fastapi security module Signed-off-by: AmirBalwel <amir.balwel@embeddedllm.com> --------- Signed-off-by: AmirBalwel <amir.balwel@embeddedllm.com> Co-authored-by: AmirBalwel <amir.balwel@embeddedllm.com>
1 parent 99bec00 commit 998c8e8

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

services/api/src/owl/entrypoints/api.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,12 @@ async def health() -> ORJSONResponse:
308308
k: openapi_schema["paths"][k]
309309
for k in sorted(
310310
openapi_schema["paths"].keys(),
311-
key=lambda p: internal_api_tag
312-
in list(openapi_schema["paths"][p].values())[0]["tags"][0],
311+
key=lambda p: (
312+
internal_api_tag in list(openapi_schema["paths"][p].values())[0]["tags"][0]
313+
),
313314
)
314315
}
315316
if ENV_CONFIG.is_cloud:
316-
# Add security schemes
317-
openapi_schema["components"]["securitySchemes"] = {
318-
"Authentication": {"type": "http", "scheme": "bearer"},
319-
}
320-
openapi_schema["security"] = [{"Authentication": []}]
321317
openapi_schema["info"]["x-logo"] = {"url": "https://www.jamaibase.com/favicon.svg"}
322318
app.openapi_schema = openapi_schema
323319

services/api/tests/utils/test_auth.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22

3+
from jamaibase import JamAI
34
from owl.types import OrgMember_, ProjectMember_, Role, UserRead
45
from owl.utils.auth import has_permissions
56
from owl.utils.dates import now
6-
from owl.utils.exceptions import ForbiddenError
7+
from owl.utils.exceptions import AuthorizationError, ForbiddenError
78

89
USER_ID = "user_id"
910
ORG_ID = "0"
@@ -124,3 +125,13 @@ def test_has_permissions():
124125
with pytest.raises(ForbiddenError):
125126
has_permissions(sys_user, ["project.member"], project_id=PROJ_ID)
126127
assert has_permissions(sys_user, ["project.guest"], project_id=PROJ_ID) is True
128+
129+
130+
@pytest.mark.cloud
131+
async def test_no_auth_token():
132+
client = JamAI(token="")
133+
with pytest.raises(
134+
AuthorizationError,
135+
match='You need to provide your PAT in an "Authorization" header',
136+
):
137+
await client.model_info()

0 commit comments

Comments
 (0)