Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
842f8eb4
Commit
842f8eb4
authored
May 10, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(studio): enforce role-aware catalog scope
parent
6638b1a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
providers.py
aisbf/routes/dashboard/providers.py
+1
-1
test_dashboard_studio.py
tests/routes/test_dashboard_studio.py
+30
-0
No files found.
aisbf/routes/dashboard/providers.py
View file @
842f8eb4
...
@@ -264,7 +264,7 @@ async def dashboard_studio_catalog(request: Request):
...
@@ -264,7 +264,7 @@ async def dashboard_studio_catalog(request: Request):
return
JSONResponse
({
"entries"
:
[],
"error"
:
"unauthorized"
},
status_code
=
401
)
return
JSONResponse
({
"entries"
:
[],
"error"
:
"unauthorized"
},
status_code
=
401
)
current_user_id
=
request
.
session
.
get
(
"user_id"
)
current_user_id
=
request
.
session
.
get
(
"user_id"
)
scope
=
"admin"
if
current_user_id
is
None
else
"user"
scope
=
"admin"
if
request
.
session
.
get
(
"role"
)
==
"admin"
else
"user"
db
=
None
if
scope
==
"admin"
else
DatabaseRegistry
.
get_config_database
()
db
=
None
if
scope
==
"admin"
else
DatabaseRegistry
.
get_config_database
()
catalog
=
build_studio_catalog
(
catalog
=
build_studio_catalog
(
...
...
tests/routes/test_dashboard_studio.py
View file @
842f8eb4
...
@@ -142,6 +142,36 @@ def test_dashboard_studio_catalog_returns_user_resources_for_user(monkeypatch):
...
@@ -142,6 +142,36 @@ def test_dashboard_studio_catalog_returns_user_resources_for_user(monkeypatch):
}
}
def
test_dashboard_studio_catalog_does_not_treat_user_role_without_user_id_as_admin
(
monkeypatch
):
client
=
TestClient
(
app
)
_set_session_cookie
(
client
,
{
"logged_in"
:
True
,
"username"
:
"demo"
,
"role"
:
"user"
,
"user_id"
:
None
,
"expires_at"
:
4102444800
,
},
)
monkeypatch
.
setattr
(
dashboard_providers
,
"build_studio_catalog"
,
lambda
**
kwargs
:
{
"scope"
:
kwargs
[
"scope"
],
"owner_id"
:
kwargs
[
"owner_id"
],
"entries"
:
[],
},
)
response
=
client
.
get
(
"/dashboard/studio/catalog"
)
assert
response
.
status_code
==
200
assert
response
.
json
()[
"scope"
]
==
"user"
assert
response
.
json
()[
"owner_id"
]
is
None
def
test_build_studio_catalog_uses_global_config_for_admin_scope
():
def
test_build_studio_catalog_uses_global_config_for_admin_scope
():
class
ModelStub
:
class
ModelStub
:
def
__init__
(
self
,
name
,
description
=
None
,
capabilities
=
None
,
context_length
=
None
,
architecture
=
None
):
def
__init__
(
self
,
name
,
description
=
None
,
capabilities
=
None
,
context_length
=
None
,
architecture
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment