Skip to content

Commit

Permalink
log credential scope mismatch on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-taussig-solo committed Sep 12, 2023
1 parent c43e2b9 commit e11ac28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions source/extensions/filters/http/aws_lambda/sts_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ class StsFetcherImpl : public StsFetcher,
// TODO: cover more AWS error cases
if (body.find(ExpiredTokenError) != std::string::npos) {
callbacks_->onFailure(CredentialsFailureStatus::ExpiredToken);
} else if (body.find(SignaturedoesNotMatchError) != std::string::npos &&
body.find(CredentialScopeMessage) != std::string::npos )
{
callbacks_->onFailure(CredentialsFailureStatus::CredentialScopeMismatch);
} else {
callbacks_->onFailure(CredentialsFailureStatus::Network);
}
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/filters/http/aws_lambda/sts_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace {
"Version=2011-06-15";

constexpr char ExpiredTokenError[] = "ExpiredTokenException";
constexpr char SignaturedoesNotMatchError[] = "SignatureDoesNotMatch";
constexpr char CredentialScopeMessage[] = "Credential should be scoped to a valid region.";
} // namespace

class StsCredentials : public Extensions::Common::Aws::Credentials {
Expand Down
4 changes: 3 additions & 1 deletion source/extensions/filters/http/aws_lambda/sts_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ enum class CredentialsFailureStatus {
/* Token is expired. */
ClusterNotFound,
/* The filter is being destroyed, therefore the request should be cancelled */
ContextCancelled
ContextCancelled,
/* The credentials computed by the filter are not valid in the current region */
CredentialScopeMismatch,
};

} // namespace AwsLambda
Expand Down

0 comments on commit e11ac28

Please sign in to comment.