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
  • Loading branch information
nowNick authored and jschmid1 committed May 31, 2024
1 parent 9641d9b commit 420b3b6
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 @@ -627,6 +627,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 = 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 = 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

1 comment on commit 420b3b6

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:420b3b6ceb17d84fb84486e0de72635fb4408c45
Artifacts available https://github.com/Kong/kong/actions/runs/9315218981

Please sign in to comment.