Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made header mapping deteministic based on order in config file instea… #38

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/authz.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ async function getRequestHeaderMapConfig(user, route) {
var requestHeaderMap = route.request_header_map_inline
}

for (var group of userGroups) {
if (requestHeaderMap[group]) {
for (var group of Object.keys(requestHeaderMap)) {
// This is not mega efficient as often the number of groups a user is in can be large,
// however this allows the config to be deterministic if a user is a member of multiple
// groups that individually have an entry in the header map config
// Providing the user is not a member of many groups the performance should be fine
if (userGroups.includes(group)) {
result = {
...result,
...requestHeaderMap[group],
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/configs/header-mapping-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Authorization": "ThisIsATestHeaderFromTheHeaderMapping",
"X-test-Header": "another test"
},
"All Users": {
"TestHeaderFromGroup": "MultipleHeader"
},
"test-header-group": {
"TestHeaderFromGroup": "TestHeaderFromGroup"
},
Expand Down
1 change: 1 addition & 0 deletions test/e2e/tests/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Scenario('Testing Header Mapping', async ({ I }) => {
I.see("ThisIsATestHeaderFromTheHeaderMapping")
I.see("TestHeaderFromGroup")
I.dontSee("TestAbsentHeaderFromGroup")
I.dontSee("MultipleHeader")
});

Scenario('Testing Header Mapping Inline', async ({ I }) => {
Expand Down
Loading