aws / aws/aws-sdk-cpp

Aws::Auth::STSProfileCredentialsProvider does not read from ~/.aws/credentials

Abierto
#1,963 1 comentario 0 reacciones 0 asignados Ver en GitHub
bug p2
Lenguaje dominante
C++
Estrellas
2.2k
Forks
1.2k
Merge medio
4 d 11 h
PR fusionados (30 d)
13

Descripción

### Describe the bug

`Aws::Auth::STSProfileCredentialsProvider` only looks at `~/.aws/config` when trying to look up a profile, but the `aws_access_key_id ` and `aws_secret_access_key` are conventionally stored in `~/.aws/credentials`. This causes applications using this provider to fail to acquire credentials, while applications built using other SDKs and the AWS CLI correctly find credentials.

### Expected Behavior

`Aws::Auth::STSProfileCredentialsProvider` should read keys from `~/.aws/credentials` when looking for a named profile.

### Current Behavior

`Aws::Auth::STSProfileCredentialsProvider` will only read keys from `~/.aws/config` when evaluating a profile.

### Reproduction Steps

The below code tells `STSProfileCredentialsProvider` to load credentials from the profile in `argv[1]`, and then print the count of buckets in an `s3:ListBuckets` call:

```c++
#include "config.h"

#include
#include
#include
#include
#include
#include
#include

int main(int argc, const char *argv[]) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " PROFILENAME" << std::endl;
return 1;
}

Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
Aws::InitAPI(options);

Aws::S3::S3Client client(
std::make_shared(argv[1])
);
auto outcome = client.ListBuckets();
if (outcome.IsSuccess()) {
std::cout << outcome.GetResult().GetBuckets().size() << " buckets" << std::endl;
} else {
std::cout << "Error: " << outcome.GetError() << std::endl;
}

Aws::ShutdownAPI(options);
return 0;
}
```

With `aws_access_key_id` and `aws_secret_access_key` in `~/.aws/credentials`, this code will print `0 buckets`. It will list the correct number of buckets if the key fields are instead set in `~/.aws/config`.

### Possible Solution

`STSProfileCredentialsProvider` should read the `~/.aws/credentials` file when trying to load a profile.

### Additional Information/Context

_No response_

### AWS CPP SDK version used

1.9.238

### Compiler and Version used

gcc 11.3.0

### Operating System and version

Linux 5.15.43 on x86_64

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza en Aws::Auth::STSProfileCredentialsProvider y sigue cómo carga un perfil con nombre. Reproduce el problema con el programa C++ proporcionado y las credenciales almacenadas en ~/.aws/credentials. Se considera terminado cuando el proveedor obtiene las credenciales de ese archivo y la solicitud de S3 tiene éxito, mientras el comportamiento existente basado en la configuración permanece intacto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, cpp
Área
authentication
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.