-
Notifications
You must be signed in to change notification settings - Fork 81
Fix the use of multiple credential providers #8909
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
Fix the use of multiple credential providers #8909
Conversation
@@ -263,8 +263,9 @@ This guide assumes that you are using IntelliJ Ultimate, because application ser | |||
- Set the context to `/iaf-test`. | |||
__NB__: This is very important, otherwise a lot of tests will fail! | |||
- Set the following VM options: | |||
`-Ddtap.stage=LOC -DauthAliases.expansion.allowed=testalias -Dweb.port=8080 -DcredentialFactory.class=org.frankframework.credentialprovider.FileSystemCredentialFactory -DcredentialFactory.filesystem.root=/<path to source>/frankframework/test/src/main/secrets` | |||
- In the "On Update" section, select "Update Classes and Resources", so classes can be automatically updated and reloaded after project build (providing this is supported by your JDK) | |||
`-Ddtap.stage=LOC -DauthAliases.expansion.allowed=testalias -Dweb.port=8080 |
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.
De filesystem credentials zijn een half jaar geleden verwijderd, maar de docs waren niet bijgewerkt.
/** | ||
* Performs a 'safe' lookup of credentials. | ||
*/ | ||
private CredentialFactory getCredentials(FrankResource resource) { |
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.
Alias werd hier resolved, maar werd hierboven eigenlijk niet meer gebruikt
|
||
String userName; | ||
String passWord; | ||
try { | ||
CredentialFactory cf = new CredentialFactory(authAlias); |
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.
Door mijn wijziging kan dit al een nosuchelementexception throwen.
@@ -59,6 +59,9 @@ public PipeRunResult doPipe(Message message, PipeLineSession session) throws Pip | |||
result += "username does not match target"; | |||
} | |||
if (!getTargetPassword().equals(cf.getPassword())) { | |||
if (!StringUtils.isEmpty(result)) { |
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.
zonder deze change kwam hier username does not match targetpassword does not match target
uit als beide niet klopten
@@ -83,7 +84,7 @@ public boolean hasCredentials(String alias) { | |||
} | |||
|
|||
@Override | |||
public ICredentials getCredentials(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) { | |||
public ICredentials getCredentials(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) throws NoSuchElementException { |
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.
Feedback van vorige pr
* @throws ConfigurationException | ||
*/ | ||
@Test | ||
void testCertificateSettingsCanBeSet() throws ConfigurationException { |
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.
Bewijst dat alles netjes geset en configured kan wordne
idin/src/main/java/org/frankframework/extensions/idin/IdinSender.java
Outdated
Show resolved
Hide resolved
credentialProvider/src/main/java/org/frankframework/credentialprovider/CredentialFactory.java
Show resolved
Hide resolved
String alias = resource.getAuthalias(); | ||
if(StringUtils.isNotEmpty(alias)) { | ||
alias = StringResolver.substVars(alias, APP_CONSTANTS); | ||
} | ||
String username = resource.getUsername(); | ||
if(StringUtils.isNotEmpty(username)) { | ||
username = StringResolver.substVars(username, APP_CONSTANTS); | ||
if(StringUtils.isNotEmpty(resource.getUsername())) { | ||
mergedProps.setProperty("user", StringResolver.substVars(resource.getUsername(), APP_CONSTANTS)); | ||
} | ||
String password = resource.getPassword(); | ||
if(StringUtils.isNotEmpty(password)) { | ||
password = StringResolver.substVars(password, APP_CONSTANTS); | ||
if(StringUtils.isNotEmpty(resource.getPassword())) { | ||
mergedProps.setProperty("password", StringResolver.substVars(resource.getPassword(), APP_CONSTANTS)); | ||
} | ||
|
||
return new CredentialFactory(alias, username, password); |
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.
Alias wordt toch meegegeven aan de CredentialFactory ?
private static class CredentialSettings { | ||
private CredentialFactory credentialFactory; | ||
private @Setter String password; | ||
private @Getter String authAlias; | ||
|
||
public void setAuthAlias(String authAlias) { | ||
this.authAlias = authAlias; | ||
this.credentialFactory = new CredentialFactory(authAlias); | ||
} | ||
|
||
public String getPassword() { | ||
if (credentialFactory == null) { | ||
return password; | ||
} | ||
|
||
return credentialFactory.getPassword(); | ||
} | ||
} |
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.
Waarom gebruik je niet 3 class fields?
private @Getter String authAlias;
private @Getter String username;
private @Getter String password;
En in de configure v/d class credentialFactory = new CredentialFactory(authAlias, username, password);
?
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.
Wat bedoel je met configure class?
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.
van de*
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.
Dan heb ik 9 class fields nodig, op deze manier (dat was ook feedback van Tim), houden we het nog een beetje netjes. Gebruik van een credential factory gaat mis zonder auth alias, vandaar deze wijziging
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.
Dan kan je toch beter dit, geniek hier oplossen:
frankframework/core/src/main/java/org/frankframework/util/CredentialFactory.java
Lines 47 to 49 in b564600
public CredentialFactory(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) { | |
credentials = org.frankframework.credentialprovider.CredentialFactory.getCredentials(alias, defaultUsernameSupplier, defaultPasswordSupplier); | |
} |
Zet daar om alias een mooie if, die een https://github.com/frankframework/frankframework/blob/master/credentialProvider/src/main/java/org/frankframework/credentialprovider/Credentials.java teruggeeft zonder alias?
(cherry picked from commit 30c8674)
core/src/main/java/org/frankframework/jdbc/datasource/ObjectCreator.java
Outdated
Show resolved
Hide resolved
…tps://github.com/frankframework/frankframework into issue/8879-support-multiple-credential-providers
|
@@ -45,10 +46,13 @@ public CredentialFactory(String alias, String defaultUsername, String defaultPas | |||
} | |||
|
|||
public CredentialFactory(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) { | |||
credentials = org.frankframework.credentialprovider.CredentialFactory.getCredentials(alias, defaultUsernameSupplier, defaultPasswordSupplier); | |||
if (alias == null) { | |||
credentials = new Credentials(alias, defaultUsernameSupplier, defaultPasswordSupplier); |
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.
Ja dit is nu wat voorheen op CredentialFactory (in cf module) op regel 130 stond!
(cherry picked from commit 4b4fc26) # Conflicts: # core/src/main/java/org/frankframework/pipes/CredentialCheckingPipe.java # credentialProvider/src/main/java/org/frankframework/credentialprovider/delinea/DelineaCredentialFactory.java
(cherry picked from commit 4b4fc26)
closes #8879