aws / aws/aws-sdk-java-v2

[IAM/STS] client doesn't work with customized endpoint

Open
#3,387 3 comments 4 reactions 0 assignees View on GitHub
bug p2
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

### Describe the bug

I tried to use v2 SDK to send AssumeRole request to my own STS service with below code, I configured endpoint to my own sts app, but the request finally just send to `https://host-ip` , path is missing which cause the request can't be send to right service

```
AttributeMap clientAttrs = AttributeMap.builder()
.put(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, true)
.build();
SdkHttpClient sdkHttpClient = new DefaultSdkHttpClientBuilder().buildWithDefaults(clientAttrs);
final StsClient stsClient = StsClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(StaticCredentialsProvider.create(cred))
.endpointOverride(URI.create("https://host-ip/sts"))
.httpClient(sdkHttpClient)
.build();
```
Traced SDK code, found the cause is [https://github.com/aws/aws-sdk-java-v2/blob/master/core/protocols/aws-query-protoc[…]/protocols/query/internal/marshall/QueryProtocolMarshaller.java](https://github.com/aws/aws-sdk-java-v2/blob/master/core/protocols/aws-query-protocol/src/main/java/software/amazon/awssdk/protocols/query/internal/marshall/QueryProtocolMarshaller.java#L55)
it hardcoded path as empty string here.
```
private SdkHttpFullRequest.Builder fillBasicRequestParams(OperationInfo operationInfo) {
return ProtocolUtils.createSdkHttpRequest(operationInfo, endpoint)
.encodedPath("")
.putRawQueryParameter("Action", operationInfo.operationIdentifier())
.putRawQueryParameter("Version", operationInfo.apiVersion());
}
```

### Expected Behavior

expect request can save correct path provided through endpointOverride interface

### Current Behavior

QueryProtocolMarshaller.java#L55)
it hardcoded path as empty string

### Reproduction Steps

check in bug description

### Possible Solution

QueryProtocolMarshaller.java#L55)
it hardcoded path as empty string here. **I think it's better to get from `endpoint`** ,
```
private SdkHttpFullRequest.Builder fillBasicRequestParams(OperationInfo operationInfo) {
return ProtocolUtils.createSdkHttpRequest(operationInfo, endpoint)
.encodedPath("")
.putRawQueryParameter("Action", operationInfo.operationIdentifier())
.putRawQueryParameter("Version", operationInfo.apiVersion());
}
```

### Additional Information/Context

_No response_

### AWS Java SDK version used

V2

### JDK version used

java version "11.0.12" 2021-07-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)

### Operating System and version

SUSE15

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.