Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws auth: add missing auth methods #3597

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

famarting
Copy link
Contributor

@famarting famarting commented Nov 12, 2024

Description

Testing AWS IAM auth with postgres and missing the assume role feature that its documented as part of the aws auth profile

It all started because this error check here is bad https://github.com/dapr/components-contrib/blob/main/common/authentication/aws/aws.go#L133
if there is no error, errors.Is(err, config.SharedConfigAssumeRoleError{}.Err) always evaluates to true... because when you do config.SharedConfigAssumeRoleError{}.Err then Err is nil!

I started fixing that but then looking at the kafka pubsub component https://github.com/dapr/components-contrib/blob/main/common/component/kafka/auth.go#L99 , kafka supports more fields, so it made sense to also support these for postgres.

docs updated here dapr/docs#4429

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation / Created issue in the https://github.com/dapr/docs/ repo: dapr/docs#[issue number]

@famarting famarting requested review from a team as code owners November 12, 2024 16:41
common/authentication/aws/aws.go Show resolved Hide resolved
return awsRegion, awsAccessKey, awsSecretKey, nil
awsSessionToken, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "AWSSessionToken")

awsIamRoleArn, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "awsIamRoleArn")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
awsIamRoleArn, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "awsIamRoleArn")
assumeRoleArn, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "assumeRoleArn")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cannot be changed, it must match with metadata.yaml , metadata.yaml has been set to match the existing metadata names for the kafka component, so we have consistency

awsSessionToken, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "AWSSessionToken")

awsIamRoleArn, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "awsIamRoleArn")
awsStsSessionName, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "awsStsSessionName")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
awsStsSessionName, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "awsStsSessionName")
sessionName, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "sessionName")

I don't think we need to expose to end users the underlying mechanisms leveraging Sts through which one can assume a new role with new creds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cannot be changed, it must match with metadata.yaml , metadata.yaml has been set to match the existing metadata names for the kafka component, so we have consistency

@@ -118,40 +119,66 @@ type AWSIAMAuthOptions struct {
Region string `json:"region" mapstructure:"region"`
AccessKey string `json:"accessKey" mapstructure:"accessKey"`
SecretKey string `json:"secretKey" mapstructure:"secretKey"`
SessionToken string `json:"sessionToken" mapstructure:"sessionToken"`

AssumeRoleArn string `json:"assumeRoleArn" mapstructure:"assumeRoleArn"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed to change this fields tags, but they are not used for anything

Signed-off-by: Fabian Martinez <[email protected]>
@famarting famarting mentioned this pull request Nov 14, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants