Skip to content

Commit

Permalink
aws_credentials_provider_new_sts() checks that role_arn and role_sess…
Browse files Browse the repository at this point in the history
…ion_name are set.
  • Loading branch information
graebm committed Jul 30, 2024
1 parent d6f5b96 commit 77b8c36
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/credentials_provider_sts.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,18 @@ struct aws_credentials_provider *aws_credentials_provider_new_sts(
return NULL;
}

if (options->role_arn.len == 0) {
AWS_LOGF_ERROR(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "role_arn is necessary for querying STS");
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
return NULL;
}

if (options->session_name.len == 0) {
AWS_LOGF_ERROR(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "role_session_name is necessary for querying STS");
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
return NULL;
}

struct aws_credentials_provider *provider = NULL;
struct aws_credentials_provider_sts_impl *impl = NULL;
int result = AWS_OP_ERR;
Expand Down Expand Up @@ -796,14 +808,14 @@ struct aws_credentials_provider *aws_credentials_provider_new_sts(
aws_string_new_from_array(allocator, options->session_name.ptr, options->session_name.len);
AWS_LOGF_DEBUG(
AWS_LS_AUTH_CREDENTIALS_PROVIDER,
"(id=%p): using session_name '%s'",
"(id=%p): using role_session_name '%s'",
(void *)provider,
aws_string_c_str(impl->role_session_name));

impl->assume_role_profile = aws_string_new_from_array(allocator, options->role_arn.ptr, options->role_arn.len);
AWS_LOGF_DEBUG(
AWS_LS_AUTH_CREDENTIALS_PROVIDER,
"(id=%p): using assume_role_arn '%s'",
"(id=%p): using role_arn '%s'",
(void *)provider,
aws_string_c_str(impl->assume_role_profile));

Expand Down

0 comments on commit 77b8c36

Please sign in to comment.