fix: strip model params for read-only callers in the model list endpoint (#27004)
The per-id model endpoint (GET /api/v1/models/model) strips params, the system prompt and other curated model config, for callers who only have read access. The list endpoint (GET /api/v1/models/list) did not: it returned each read-accessible model's full params, so a read-shared model exposed its params.system to non-owner read-grant holders. Mirror the per-id behaviour: compute write_access per item and drop params before serialising when the caller lacks write access (not the owner, not an admin under BYPASS_ADMIN_ACCESS_CONTROL and holding no write grant). The model-card list UI does not render params, so this does not change functionality. Co-authored-by: bogdancherniy11-sudo <229690748+bogdancherniy11-sudo@users.noreply.github.com>
This commit is contained in:
1 parent
c05de13b4f
commit
3fe829acc2
1 file changed
+9
-9
@@ -189,16 +189,16 @@ async def get_models(
|
|||||||
data = add_chat_variables_schema(model.model_dump())
|
data = add_chat_variables_schema(model.model_dump())
|
||||||
if data.get('meta'):
|
if data.get('meta'):
|
||||||
data['meta'].pop('profile_image_url', None)
|
data['meta'].pop('profile_image_url', None)
|
||||||
items.append(
|
write_access = (
|
||||||
ModelAccessResponse(
|
(user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL)
|
||||||
**data,
|
or user.id == model.user_id
|
||||||
write_access=(
|
or model.id in writable_model_ids
|
||||||
(user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL)
|
|
||||||
or user.id == model.user_id
|
|
||||||
or model.id in writable_model_ids
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
# Strip params (system prompt and other curated config) for read-only
|
||||||
|
# callers, mirroring the per-id endpoint.
|
||||||
|
if not write_access:
|
||||||
|
data['params'] = {}
|
||||||
|
items.append(ModelAccessResponse(**data, write_access=write_access))
|
||||||
|
|
||||||
return ModelAccessListResponse(
|
return ModelAccessListResponse(
|
||||||
items=items,
|
items=items,
|
||||||
|
|||||||
Reference in new issue
Block a user