feat: allow multiple header values in upstream headers configuration#252
Conversation
|
Hi @Prototik, Headers:
- Name: "Impersonate-Group"
Value: "developers"
- Name: "Impersonate-Group"
Value: "admins"But the problem is that with this approach it cannot be dynamic. Should we maybe provide a custom helper function so that it's easier to map an array? 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. |
|
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)) }}' |
db5b9d4 to
1d7d8d5
Compare
sevensolutions
left a comment
There was a problem hiding this comment.
Many thanks @Prototik, great work 👍
Just one small thing we should check and then I'am happy to merge it.
db967ae to
409a3ab
Compare
409a3ab to
66a26e1
Compare
|
Thank you @Prototik, looks good now. |
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.