aws / aws/aws-sdk-java-v2

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

Aperta
#3,387 3 commenti 4 reazioni 0 assegnatari Vedi su GitHub
bug p2
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da core/protocols/aws-query-protocol/src/main/java/software/amazon/awssdk/protocols/query/internal/marshall/QueryProtocolMarshaller.java e riproduci la richiesta AssumeRole usando l’esempio endpointOverride nell’issue. Il lavoro è completato quando la richiesta mantiene il percorso /sts configurato invece di essere inviata solo a https://host-ip.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.