-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(vault): allow arrays in conf loader to be referenced #12672
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2db7703
to
78faecc
Compare
78faecc
to
004f175
Compare
fff37df
to
b1ab67e
Compare
21a9e28
to
5bfd1e7
Compare
5bfd1e7
to
ae30a71
Compare
### Summary Some properties, like `KONG_SSL_CERT` and `KONG_SSL_CERT_KEY` are arrays and users can specify many. Vaults didn't work in this scenario: For example below didn't work before: ``` CERT_1=$(<cert1.crt) \ KEY_1=$(<key1.key) \ CERT_2=$(<cert2.crt) \ KEY_2=$(<key2.key) \ KONG_SSL_CERT_KEY="{vault://env/key-1},{vault://env/key-2}" \ KONG_SSL_CERT="{vault://env/cert-1},{vault://env/cert-2}" \ kong prepare --vv ``` There were also erroneous warning in logs like because of bad array handling: ``` [warn] 680#0: [kong] vault.lua:1475 error caching secret reference {vault://env/cert-1}: bad value type ``` This fixes those. Signed-off-by: Aapo Talvensaari <[email protected]>
ae30a71
to
bb3190b
Compare
windmgc
reviewed
Nov 7, 2024
return nil, err | ||
end | ||
|
||
-- TODO: remember! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bungle Do you still remember what is the exact todo item here? I'm working to finish this PR
3 tasks
windmgc
added a commit
that referenced
this pull request
Nov 29, 2024
…bsystem (#13855) * fix(vault): allow arrays in conf loader to be referenced ### Summary The commit includes the following fix for vault: Fix the issue that array-type configuration's element cannot be referenced. conf_loader now supports iterate through array-like configuration field and deref the secrets one by one. Enable the vault to dereference secrets using partial SSL configurations, for example, lua_ssl_trusted_certificate=system, {vault://abc/def}. This is implemented especially for resty environments that execute the actual kong command, with the opts pre_cmd = true. Vault related functionalities can work normally by using valid partial configuration generated in the pre_cmd environment. This change does not have a separate changelog entry because it is part of the previous "array-type config vault ref" fix and is more inline with user's intuition. Fix the issue that vault reference cannot work well when multiple subsystems(http/stream) are enabled. The kong_processed_secrets environment variable/file are now generated by subsystems, so enabling multiple subsystem will generates multiple env var/secret file for storing vault deref result. * fix(vault): allow arrays in conf loader to be referenced (#12672) * fix(*): special treatment for pre_cmd * fix(cmd): fix vault refs when both http and stream are enabled * tests(*): fix prepare cmd test * tests(*): add vault related cmd tests * docs(changelog): add changelog * test(*): try to fix test * fix(*): unsetenv unconditionally clean http/stream env --------- Signed-off-by: Aapo Talvensaari <[email protected]> Co-authored-by: Aapo Talvensaari <[email protected]>
github-actions bot
pushed a commit
that referenced
this pull request
Nov 29, 2024
…bsystem (#13855) * fix(vault): allow arrays in conf loader to be referenced ### Summary The commit includes the following fix for vault: Fix the issue that array-type configuration's element cannot be referenced. conf_loader now supports iterate through array-like configuration field and deref the secrets one by one. Enable the vault to dereference secrets using partial SSL configurations, for example, lua_ssl_trusted_certificate=system, {vault://abc/def}. This is implemented especially for resty environments that execute the actual kong command, with the opts pre_cmd = true. Vault related functionalities can work normally by using valid partial configuration generated in the pre_cmd environment. This change does not have a separate changelog entry because it is part of the previous "array-type config vault ref" fix and is more inline with user's intuition. Fix the issue that vault reference cannot work well when multiple subsystems(http/stream) are enabled. The kong_processed_secrets environment variable/file are now generated by subsystems, so enabling multiple subsystem will generates multiple env var/secret file for storing vault deref result. * fix(vault): allow arrays in conf loader to be referenced (#12672) * fix(*): special treatment for pre_cmd * fix(cmd): fix vault refs when both http and stream are enabled * tests(*): fix prepare cmd test * tests(*): add vault related cmd tests * docs(changelog): add changelog * test(*): try to fix test * fix(*): unsetenv unconditionally clean http/stream env --------- Signed-off-by: Aapo Talvensaari <[email protected]> Co-authored-by: Aapo Talvensaari <[email protected]> (cherry picked from commit bc0acea)
3 tasks
windmgc
added a commit
that referenced
this pull request
Nov 29, 2024
…bsystem (#13855) * fix(vault): allow arrays in conf loader to be referenced ### Summary The commit includes the following fix for vault: Fix the issue that array-type configuration's element cannot be referenced. conf_loader now supports iterate through array-like configuration field and deref the secrets one by one. Enable the vault to dereference secrets using partial SSL configurations, for example, lua_ssl_trusted_certificate=system, {vault://abc/def}. This is implemented especially for resty environments that execute the actual kong command, with the opts pre_cmd = true. Vault related functionalities can work normally by using valid partial configuration generated in the pre_cmd environment. This change does not have a separate changelog entry because it is part of the previous "array-type config vault ref" fix and is more inline with user's intuition. Fix the issue that vault reference cannot work well when multiple subsystems(http/stream) are enabled. The kong_processed_secrets environment variable/file are now generated by subsystems, so enabling multiple subsystem will generates multiple env var/secret file for storing vault deref result. * fix(vault): allow arrays in conf loader to be referenced (#12672) * fix(*): special treatment for pre_cmd * fix(cmd): fix vault refs when both http and stream are enabled * tests(*): fix prepare cmd test * tests(*): add vault related cmd tests * docs(changelog): add changelog * test(*): try to fix test * fix(*): unsetenv unconditionally clean http/stream env --------- Signed-off-by: Aapo Talvensaari <[email protected]> Co-authored-by: Aapo Talvensaari <[email protected]> (cherry picked from commit bc0acea)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cherry-pick kong-ee
schedule this PR for cherry-picking to kong/kong-ee
core/cli
core/configuration
core/db
core/pdk
schema-change-noteworthy
size/L
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Some properties, like
KONG_SSL_CERT
andKONG_SSL_CERT_KEY
are arrays and users can specify many. Vaults didn't work in this scenario:For example below didn't work before:
There were also erroneous warning in logs like because of bad array handling:
This fixes those.
The other commit is just a small refactor on schema:
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssues Resolved
KAG-3869
FTI-6163