Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit f6423ad

Browse files
committed
Polishing external HTTP credentials support for the Shell
1 parent e828aad commit f6423ad

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/TargetCredentials.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ public class TargetCredentials {
3737

3838
private final String password;
3939

40+
private final boolean usesAccessToken;
41+
4042
public TargetCredentials(String username, String password) {
4143
this.username = username;
4244
this.password = password;
45+
this.usesAccessToken = false;
46+
}
47+
48+
public TargetCredentials(boolean usesAccessToken) {
49+
super();
50+
this.username = null;
51+
this.password = null;
52+
this.usesAccessToken = usesAccessToken;
4353
}
4454

4555
public String getUsername() {
@@ -51,7 +61,12 @@ public String getPassword() {
5161
}
5262

5363
public String getDisplayableContents() {
54-
return "[username='" + username + "', password='********']";
64+
if (this.usesAccessToken) {
65+
return "[Uses OAuth2 Access Token]";
66+
}
67+
else {
68+
return "[username='" + username + "', password='********']";
69+
}
5570
}
5671

5772
public List<RoleType> getRoles() {

spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/command/ConfigCommands.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.cloud.dataflow.rest.util.ProcessOutputResource;
4444
import org.springframework.cloud.dataflow.rest.util.ResourceBasedAuthorizationInterceptor;
4545
import org.springframework.cloud.dataflow.shell.Target;
46+
import org.springframework.cloud.dataflow.shell.TargetCredentials;
4647
import org.springframework.cloud.dataflow.shell.TargetHolder;
4748
import org.springframework.cloud.dataflow.shell.command.support.RoleType;
4849
import org.springframework.cloud.dataflow.shell.config.DataFlowShell;
@@ -195,6 +196,7 @@ public String target(
195196
httpClientConfigurer.basicAuthCredentials(targetUsername, targetPassword);
196197
}
197198
if (StringUtils.hasText(credentialsProviderCommand)) {
199+
this.targetHolder.getTarget().setTargetCredentials(new TargetCredentials(true));
198200
final Resource credentialsResource = new ProcessOutputResource(credentialsProviderCommand.split("\\s+"));
199201
httpClientConfigurer.addInterceptor(new ResourceBasedAuthorizationInterceptor(credentialsResource));
200202
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Data Flow Options:
2-
--dataflow.uri=<uri> Address of the Data Flow Server [default: http://localhost:9393].
3-
--dataflow.username=<USER> Username of the Data Flow Server [no default].
4-
--dataflow.password=<PASSWORD> Password of the Data Flow Server [no default].
5-
--dataflow.skip-ssl-validation=<true|false> Accept any SSL certificate (even self-signed) [default: no].
6-
--spring.shell.historySize=<SIZE> Default size of the shell log file [default: 3000].
7-
--spring.shell.commandFile=<FILE> Data Flow Shell executes commands read from the file(s) and then exits.
8-
--help This message.
2+
--dataflow.uri=<uri> Address of the Data Flow Server [default: http://localhost:9393].
3+
--dataflow.username=<USER> Username of the Data Flow Server [no default].
4+
--dataflow.password=<PASSWORD> Password of the Data Flow Server [no default].
5+
--dataflow.credentials-provider-command=<COMMAND> Executes an external command which must return an OAuth Access Token [no default].
6+
--dataflow.skip-ssl-validation=<true|false> Accept any SSL certificate (even self-signed) [default: no].
7+
--spring.shell.historySize=<SIZE> Default size of the shell log file [default: 3000].
8+
--spring.shell.commandFile=<FILE> Data Flow Shell executes commands read from the file(s) and then exits.
9+
--help This message.

0 commit comments

Comments
 (0)