-
Notifications
You must be signed in to change notification settings - Fork 124
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
Secret Keys Handlers #833
Secret Keys Handlers #833
Conversation
/cc @dmlloyd @sberyozkin |
implementation/src/main/java/io/smallrye/config/SecretKeysConfigSourceInterceptor.java
Outdated
Show resolved
Hide resolved
0c84602
to
b60e9b1
Compare
@dmlloyd let me know what you think of the current proposal. Thanks! |
implementation/src/main/java/io/smallrye/config/ExpressionConfigSourceInterceptor.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/ConfigValue.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/SecretKeysHandler.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/SecretKeys.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/SecretKeys.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/SecretKeys.java
Outdated
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/config/SecretKeysHandlerConfigSourceInterceptor.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,27 @@ | |||
package io.smallrye.config; | |||
|
|||
public class SecretKeysHandlerConfigSourceInterceptor implements ConfigSourceInterceptor { |
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.
This makes sense to me. We can look up secret values separately from extracting them from an expression, which also allows specialized config sources that might encode them in an idiomatic way. 👍
public class KeyStoreConfigSourceFactory implements ConfigSourceFactory { | ||
@Override | ||
public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context) { | ||
SmallRyeConfig config = new SmallRyeConfigBuilder() |
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.
So this config source requires a full config in order to work? If so, this gets away from the single-config methodology twice, once by requiring a config for the config and once for the key store itself.
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.
Not exactly. This is just a trick to be able to use a mapping to configure a ConfigSource.
For instance, consider the mapping:
https://github.com/radcortez/smallrye-config/blob/b2bf955328cf8e4382c364f898173477d80d77a3/sources/keystore/src/main/java/io/smallrye/config/source/keystore/KeyStoreConfig.java#L11
How can we create this mapping? Remember, we use SmallRyeConfig
to call certain API to populate the mapping instance. Ideally, we should decouple that, so we don't need to use the trick.
We create an empty SmallRyeConfig
instance, just with the mapping class and a ConfigSource
that delegates to the ConfigSourceContext
:
So we can get an instance of the mapping class, by wrapping all of that, but still use the original config context being build.
1fa5151
to
2f00ae1
Compare
2f00ae1
to
96ce934
Compare
implementation/src/main/java/io/smallrye/config/ExpressionConfigSourceInterceptor.java
Show resolved
Hide resolved
96ce934
to
dddcc4b
Compare
6ddbf89
to
c6d1e19
Compare
preface: the following could be very dumb as I'm not acquainted with this project in particular, but seeing that other parts seem to support dynamic loading of config changes, e.g. the following PR https://github.com/smallrye/smallrye-config/pull/152/files#diff-60faeb32cc934956c4bbc5ac22b81c35f9c9fc6e8073e83779bb1cfbe00d7cb9 ... Also, I'm sorry I'm discussing it here but I couldn't find a related issue on the matter. I'm curious to learn if it shouldn't also be possible to load changes of these secrets as well? For instance, a file containing a password file should probably trigger an event if it is changed so that a consuming application could simply reload. However, as mentioned, it seems some part of this project support it but I'm finding it hard to understand if this PR builds on that or not? To give an example: will a change of a secretvalue lead to an event being fired that can be caught by, let's say, KeyCloak (which uses quarkus) which would be able to restart a connection to a backend resource? |
You don't need to apologize :)
No, we don't build on that. What determines how a configuration is read (and if it is reloadable), is the
Our stance with Quarkus is that we don't support reloadable configuration (at least the configuration on the |
Thanks for your elaborate reply on the matter, really appreciate it and I understand it fully :-) Happy coding! |
Hey @radcortez, as I'm continuing with the spike around this PR, I encountered another issue (hopefully this time it's not something already known 😊) . It seems that when you work with the Keystore Config Source and Lines 149 to 152 in dddcc4b
is not handled properly. In my scenario, where single property file is shared among multiple tests, it affected all of them. I tried a quick fix, where I caught the exception here: Line 235 in dddcc4b
So now the line looks like this: catch (FileNotFoundException | NoSuchFileException | RuntimeException e) { and it helped. But you may find a more elegant solution, for sure 😊. Thanks! |
Thanks! Let me have a look! |
@radcortez I just wanted to ask whether there is a progress regarding this? On top of that, what secret handlers are planned to be present in the final implementation? I tried the Is this still aimed for the Quarkus 3 release? Thanks! |
Hey. I'm sorry, I was on PTO the last few days so I couldn't look into it, but it is on my plans to look as soon as possible. I still need to do the final move to Jakarta (including other SR Projects), and then we should be ready to go with new features. Yes, the The idea is to add handlers as required, so if you need a specific one, feel free to add it. |
4d6a7af
to
3ef8368
Compare
I have fixed some of the issues and added some of the missing pieces (namely, supporting a way to configure the secret handlers). Can you take a final look? Thanks :) |
b240404
to
0931111
Compare
b9baa8d
to
cfb1742
Compare
Hey @radcortez , do you think it is possible for you to release SmallRye Config and bump the version in Quarkus once this gets merged? I'd like to do QE test development for this - https://issues.redhat.com/browse/QUARKUS-2727. I hope release won't eat too much of your time. Thank you |
I'm currently working on the Quarkus integration bits and I believe it should be completed in the next few days. Thanks! |
cfb1742
to
1332096
Compare
1332096
to
e456404
Compare
Replaces #799.
${handler_name::encoded_secret}
.SecretKeys
API, registers handlers by name via the ServiceLoader.SecretKeysHandler
is executed in the interceptor that deals with secret keys (if there is a match).KeyStore
source, to demonstrate how it could work with theSecretKeysHandler
.There is still some work to complete:
SecretKeysHandler
.The goal of the current PR is to just agree on the design and then move forward.