Skip to content

Commit

Permalink
fix(plugins): add realm to removed fields
Browse files Browse the repository at this point in the history
Basic-auth and key-auth added new field "realm"
but it was not added to "removed_fields" which breaks backwards compat
between new CPs and old DPs. Adding realm to removed fields
fixes the issue.

KAG-4516

(cherry picked from commit 420b3b6)
  • Loading branch information
nowNick authored and bungle committed Jun 11, 2024
1 parent 2026dcc commit d7a25df
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: "**Basic-Auth**: Fix an issue of realm field not recognized for older kong versions (before 3.6)"
type: bugfix
scope: Plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: "**Key-Auth**: Fix an issue of realm field not recognized for older kong versions (before 3.7)"
type: bugfix
scope: Plugin
6 changes: 6 additions & 0 deletions kong/clustering/compat/removed_fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ return {
opentelemetry = {
"sampling_rate",
},
basic_auth = {
"realm"
}
},

-- Any dataplane older than 3.7.0
Expand All @@ -135,5 +138,8 @@ return {
ai_response_transformer = {
"llm.model.options.upstream_path",
},
key_auth = {
"realm"
}
},
}
33 changes: 33 additions & 0 deletions spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,39 @@ describe("CP/DP config compat transformations #" .. strategy, function()
admin.plugins:remove({ id = ai_response_transformer.id })
end)
end)

describe("www-authenticate header in plugins (realm config)", function()
it("[basic-auth] removes realm for versions below 3.6", function()
local basic_auth = admin.plugins:insert {
name = "basic-auth",
}

local expected_basic_auth_prior_36 = utils.cycle_aware_deep_copy(basic_auth)
expected_basic_auth_prior_36.config.realm = nil

do_assert(utils.uuid(), "3.5.0", expected_basic_auth_prior_36)

-- cleanup
admin.plugins:remove({ id = basic_auth.id })
end)

it("[key-auth] removes realm for versions below 3.7", function()
local key_auth = admin.plugins:insert {
name = "key-auth",
config = {
realm = "test"
}
}

local expected_key_auth_prior_37 = utils.cycle_aware_deep_copy(key_auth)
expected_key_auth_prior_37.config.realm = nil

do_assert(utils.uuid(), "3.6.0", expected_key_auth_prior_37)

-- cleanup
admin.plugins:remove({ id = key_auth.id })
end)
end)
end)
end)

Expand Down

0 comments on commit d7a25df

Please sign in to comment.