-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Uses label when searching secrets in [Spring]VaultEnvironmentRepository #2460
Conversation
So this will break existing apps since the location in vault will be different now? |
Yes, the secret keys should include a label (mostly |
IMO this will be problematic to include in anything but a major in its current form. What if we didn't include the label in the key if it is the same as the default label? That would preserve the existing behavior for the more part. I also want to run this by the rest of the team to see what they think. |
Right, If we skip appending label to the key if it is same as default label ( |
The default is
I guess I wonder if anyone is using a label and if so why if it was never actually used with Vault? |
Default label is only configurable for some backends like Regarding your second point: |
Got it. After discussing with the team we think that this new functionality should be wrapped in a feature flag which is disabled by default and should only go into main. |
@ryanjbaxter |
@ryanjbaxter would you mind having a look at latest changes (feature flag) ? |
Looks good, can you document the new property? |
@ryanjbaxter while trying to update the documents, I just realised an ambiguity in the secret path which is introduced by my changes. A complete secret key would be something like
The simplest solution which I can think of is always including the profile (even if it is default) in the valut key. So that we have a fix key format consist of 3 separate segments ( Note: Since we have the feature flag for the changes in this PR, It should not break any existing functionality. |
I agree with this. When making a request to the config server only the label is optional in the path, you must include the application name and profile even if that profile is default. So it makes sense that we require the application name and profile in the key.
Does that mean today that we don't require the profile when creating the key today? |
yes, the profile part is optional. secrets can be stored in the following paths in valut:
To keep the backward compatibility, the behaviour should stay the same when the |
Got it. But I would say that it should always have 2 segments, application and profile, label being optional. Again much like the rest API label is the only optional part. |
Label is optional in API level but when omitted a default label (currently |
@ryanjbaxter I've updated the PR and I believe it is ready for the final review. |
@kvmw one small this, I think the default label should be |
Signed-off-by: kvmw <[email protected]>
Signed-off-by: kvmw <[email protected]>
Signed-off-by: kvmw <[email protected]>
…t key Signed-off-by: kvmw <[email protected]>
Signed-off-by: kvmw <[email protected]>
Signed-off-by: kvmw <[email protected]>
@ryanjbaxter Updated the PR with |
Like other EnvironmentRepositories,
VaultEnvironmentRepository::findOne
andSpringVaultEnvironmentRepository::findOne
should use thelabel
argument passed to them when searching for secrets in vault.So calling
findOne("my-app", "my-profile", "my-label")
should search for secrets in vault in the following locations with the exact order:secret/myapp,my-profile,my-label
secret/application,my-profile,my-label
(Assumingapplication
is the default-key)secret/myapp,my-label
secret/application,my-label
(Assumingapplication
is the default-key)Currently the search locations are the followings (note the missing label):
secret/myapp,my-profile
secret/application,my-profile
(Assumingapplication
is the default-key)secret/myapp
secret/application
(Assumingapplication
is the default-key)This PR fixes the above issue.
Breaking Change
Since this wrong behaviour has been there from the day one, based on my knowledge, everyone using the vault backend has been relying on it and they have been adding their vault secrets in the wrong location (without label). Fixing this behaviour is going to break all those applications using the vault backend.
Update 23 Sep. 2024
I've updated the PR with the following changes:
Added a feature flag (
enableLabel
) for the new changes (using label in search). The feature flag (enableLabel
) isoff
by default.Added the
defaultLabel
to Vault properties. It ismaster
by default and only used when above feature flag ison
.When above feature flag is
on
, the vault secrets should have always all three segments ([application name | 'application'],[profile | 'default'],[label | 'master']
) in their paths.Updated the vault docs.