Skip to content

feat: allow multiple header values in upstream headers configuration#252

Merged
sevensolutions merged 4 commits intosevensolutions:mainfrom
Prototik:multiple-header-values
Feb 8, 2026
Merged

feat: allow multiple header values in upstream headers configuration#252
sevensolutions merged 4 commits intosevensolutions:mainfrom
Prototik:multiple-header-values

Conversation

@Prototik
Copy link
Contributor

First of all: thanks for this awesome plugin!

I'm integrating oidc auth in some app which uses kubernetes api and was required to pass multiple values for a header due to how user impersonation works on kubernetes. Unfortunately, this project lacks this ability... until now I guess.

To pass a list of values through all that yaml stuff I couldn't think anything better to pass a template which produces a json array, which values I set to header values. If anyone have a better idea - welcome to comments.

I tested this patch with a real app and it works flawlessly.

@sevensolutions
Copy link
Owner

Hi @Prototik,
thx for submitting this PR.
I'am just thinking if we can find a better way of providing the values.
What immediately came to my mind was simply allowing to specify the same header multiple times.
Eg.

Headers:
  - Name: "Impersonate-Group"
    Value: "developers"
  - Name: "Impersonate-Group"
    Value: "admins"

But the problem is that with this approach it cannot be dynamic.
Your approach allows you to loop over and map every group automatically so i think thats a good solution.

Should we maybe provide a custom helper function so that it's easier to map an array?
Something like:

Headers:
  - Name: "Impersonate-Group"
    Values: '[{{ mapArray(.claim.groups) }}]'

Spoiler: I have no idea yet if this is possible.. Didn't check that yet.

But on the other side, it's an edge case anyway.

@Prototik
Copy link
Contributor Author

Prototik commented Feb 1, 2026

After a bit of tinkering I ended with three additional functions for templates, withPrefix/withSuffix (self-explanatory I guess) and mapToJsonArray, which takes slice of strings and outputs valid json directly, without manual tinkering. So current example is

  - Name: "Impersonate-Group"
    Values: '{{ .claims.groups | withPrefix "prefix:" | mapToJsonArray }}'

Or in imperative style:

  - Name: "Impersonate-Group"
    Values: '{{ mapToJsonArray(withPrefix("prefix:", .claims.groups)) }}'

@Prototik Prototik force-pushed the multiple-header-values branch from db5b9d4 to 1d7d8d5 Compare February 1, 2026 17:30
Copy link
Owner

@sevensolutions sevensolutions left a comment

Choose a reason for hiding this comment

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

Many thanks @Prototik, great work 👍
Just one small thing we should check and then I'am happy to merge it.

@Prototik Prototik force-pushed the multiple-header-values branch from db967ae to 409a3ab Compare February 4, 2026 20:08
@Prototik Prototik force-pushed the multiple-header-values branch from 409a3ab to 66a26e1 Compare February 5, 2026 10:37
@sevensolutions
Copy link
Owner

Thank you @Prototik, looks good now.
Please give me a 👍 when you're happy with it and I'll merge it.

@sevensolutions sevensolutions merged commit c46fb61 into sevensolutions:main Feb 8, 2026
2 checks passed
@Prototik Prototik deleted the multiple-header-values branch February 22, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants