Skip to content

Commit

Permalink
fix(ai-proxy): user cannot select their own model if one is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Jun 3, 2024
1 parent cfd11d8 commit 08790c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kong/plugins/ai-proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ function _M:access(conf)
return bad_request(err)
end

-- check that the user isn't trying to override the plugin conf model in the request body
if request_table and request_table.model and type(request_table.model) == "string" then
if request_table.model ~= conf_m.model.name then
return bad_request("cannot use own model - must be: " .. conf_m.model.name)
end
end

-- copy from the user request if present
if (not multipart) and (not conf_m.model.name) and (request_table.model) then
conf_m.model.name = request_table.model
Expand Down

0 comments on commit 08790c3

Please sign in to comment.