Skip to content

Commit

Permalink
feat: fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl committed Aug 14, 2024
1 parent 4092f40 commit 1ae09cf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions kong/llm/drivers/anthropic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,14 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/azure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end
Expand All @@ -145,7 +145,7 @@ function _M.configure_request(conf)
or (conf.model.options and conf.model.options.azure_api_version)

if auth_param_name and auth_param_value and auth_param_location == "query" then
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
end
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/cohere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/gemini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,14 @@ function _M.configure_request(conf, identity_interface)
-- DBO restrictions makes sure that only one of these auth blocks runs in one plugin config
if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/llama2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/mistral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/drivers/openai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ function _M.configure_request(conf)

if auth_header_name and auth_header_value then
local exist_value = kong.request.get_header(auth_header_name)
if exist_value == nil or not conf.auth.can_override then
if exist_value == nil or not conf.auth.allow_auth_override then
kong.service.request.set_header(auth_header_name, auth_header_value)
end
end

if auth_param_name and auth_param_value and auth_param_location == "query" then
local query_table = kong.request.get_query()
if query_table[auth_param_name] == nil or not conf.auth.can_override then
if query_table[auth_param_name] == nil or not conf.auth.allow_auth_override then
query_table[auth_param_name] = auth_param_value
kong.service.request.set_query(query_table)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/llm/schemas/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ local auth_schema = {
required = false,
encrypted = true,
referenceable = true }},
{ can_override = {
{ allow_auth_override = {
type = "boolean",
description = "If enabled, the auth header or param can be overridden by the request using the plugin configured value.",
description = "If enabled, the authorization header or parameter can be overridden in the request by the value configured in the plugin.",
required = false,
default = true }},
}
Expand Down

0 comments on commit 1ae09cf

Please sign in to comment.