-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Integrate Vertx HTTP with CredentialsProvider #26380
Merged
sberyozkin
merged 1 commit into
quarkusio:main
from
sberyozkin:vertx_http_credentials_provider
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
...tion-tests/bouncycastle-jsse/src/main/java/io/quarkus/it/bouncycastle/SecretProvider.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.it.bouncycastle; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
import io.quarkus.credentials.CredentialsProvider; | ||
|
||
@ApplicationScoped | ||
@Unremovable | ||
public class SecretProvider implements CredentialsProvider { | ||
|
||
@Override | ||
public Map<String, String> getCredentials(String credentialsProviderName) { | ||
Map<String, String> creds = new HashMap<>(); | ||
creds.put("keystore-password", "password"); | ||
creds.put("truststore-password", "password"); | ||
return creds; | ||
} | ||
|
||
} |
6 changes: 4 additions & 2 deletions
6
integration-tests/bouncycastle-jsse/src/main/resources/application.properties
This file contains 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
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.
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.
How does this lookup work? Is it using
@Identifier
?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.
It looks for the named beans such as this one, this pattern of checking it is used across various Quarkus extensions. This name does not have to be specified if there is only one bean, that look up code will return the single bean it will find, only needed if several different providers are used.
Once the provider is found, the string (such as
custom
used in this PR's test) is passed to the found provider to return the credentials, it is not used here, but in Quarkus File Vault it will identify the keystore where to get the secrets from: https://quarkiverse.github.io/quarkiverse-docs/quarkus-file-vault/dev/index.html#_how_to_use_the_extension, for example:So here Agroal will pass
quarkus.file.vault.provider.db1
to the provider which will figure out thatdb1
is a keystore tag, and use itsdb1
configuration to get the data, etcThere 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.
Yeah... it uses @nAmed. I don't believe we want this. @mkouba WDYT?
My guess is that a proper qualifier would be better.
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.
@cescoffier Sure;
@Named
would only come into effect if there are more than oneCredentialsProvider
loaded, with a single one it make no difference. Not sure we can change that though as a few such providers use@Named
(the one inquarkus-vault
for example)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.
@cescoffier Sure;
@Named
would only come into effect if there are more than oneCredentialsProvider
loaded, with a single one it makes no difference. Not sure we can change that though as a few such providers use@Named
(the one inquarkus-vault
(the one based aroiund HashiCorp Vault) and alsoquarkus-file-vault
, but there could be custom ones too)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.
+1
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.
I guess it is not something that we can do in this PR, right ?
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.
@cescoffier @mkouba As far as this PR is concerned, I can make a
credentials-provider-name
property not optional but required if you are concerned about a random provider being picked up, it will ensure that only a provider with a matchingNamed
value will be picked up.I think the actual
CredentialsProvider
resolution logic update is out of scope for this PR as many extensions depend on it (making thecredentials-provider-name
required for all those extensions can be the 1st step forward), changing it willbe a breaking change and will make this PR non-backportable if it will have to be backported.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.
@cescoffier I've noticed you've approved, thanks, but your concern about
@Named
is noted for sure. As I said, I can enforce at the vertx-http level thatcredentials-provider-name
is required, however, I'm having a 2nd thought about it now, ifCredentialsProvider
resolution logic will indeed get changed in the future then havingcredentials-provider-name
explicitly required may make it harder to migrate.Perhaps a reasonable compromise is to recommend in JavaDocs of this property that it should be used, will do it now
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.
Just pushed a JavaDoc update recommending to use the name property all the time