Skip to content

Commit 3b68779

Browse files
authored
Merge pull request #17617 from iterate-ch/feature/GH-17612-context-property
Expose Context key in profile as property and allow override in bookm…
2 parents 70087dc + c3534c9 commit 3b68779

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

core/src/main/java/ch/cyberduck/core/Profile.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ public Map<String, String> getProperties() {
685685
property -> StringUtils.contains(property, '=') ? substitutor.replace(StringUtils.substringAfter(property, '=')) : StringUtils.EMPTY)));
686686
// In profile as dict
687687
properties.putAll(this.map(PROPERTIES_KEY));
688+
if(null != this.getContext()) {
689+
properties.put(CONTEXT_KEY, this.getContext());
690+
}
688691
return properties;
689692
}
690693

s3/src/main/java/ch/cyberduck/core/auth/AWSSessionCredentialsRetriever.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public Credentials get() throws BackgroundException {
7575
final HttpClientBuilder configuration = builder.build(ProxyFactory.get(),
7676
new DisabledTranscriptListener(), new DisabledLoginCallback());
7777
try (CloseableHttpClient client = configuration.build()) {
78-
final HttpRequestBase resource = new HttpGet(new HostUrlProvider().withUsername(false).withPath(true).get(address));
78+
final HttpRequestBase resource = new HttpGet(url);
7979
return client.execute(resource, response -> {
8080
switch(response.getStatusLine().getStatusCode()) {
8181
case HttpStatus.SC_OK:

s3/src/main/java/ch/cyberduck/core/s3/S3Session.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ protected S3CredentialsStrategy configureCredentialsStrategy(final HttpClientBui
268268
}
269269
if(S3Session.isAwsHostname(host.getHostname())) {
270270
// Try auto-configure
271-
if(Scheme.isURL(host.getProtocol().getContext())) {
272-
log.debug("Auto-configure credentials from instance metadata {}", host.getProtocol().getContext());
271+
final String context = preferences.getProperty(Profile.CONTEXT_KEY);
272+
if(Scheme.isURL(context)) {
273+
log.debug("Auto-configure credentials from HTTP endpoint {}", context);
273274
// Fetch temporary session token from instance metadata
274-
return new AWSSessionCredentialsRetriever(trust, key, host.getProtocol().getContext());
275+
return new AWSSessionCredentialsRetriever(trust, key, context);
275276
}
276277
}
277278
if(host.getProtocol().isRoleConfigurable() || host.getProperty(Profile.STS_ROLE_ARN_PROPERTY_KEY) != null) {

0 commit comments

Comments
 (0)