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-msk-iam-auth doesnt work for roles that have externalId and an awsAccessKey/awsSecretKey is provided to assume the role. #128

Open
lets-data opened this issue Jul 22, 2023 · 0 comments

Comments

@lets-data
Copy link

lets-data commented Jul 22, 2023

Folks,

I have a usecase where the code is running with Lambda credentials. To authenticate with Kafka, the code requires to assume a role that has an externalId.
Since we want to limit access to those who can assume the role, we limit assume role to a user's IAM user.
So the lambda code retrieves the user's IAM credentials (aws accessKey + aws secretKey) and passes these credentials and the role with externalId and the externalId in the jaas config. This gives an error since the code doesn't seem to set the externalId when aws credentials and role is specified.
If we remove the externalId condition from the role policy, this starts working.

I have made a private fix where I have modified the MSKCredentialProvider.java to include the externalId. I am attaching a diff screenshot on the fix that I have made. Can you see if this fix needs to be done for mainline?
image

Here is the example jaas config that my java code is using:

"software.amazon.msk.auth.iam.IAMLoginModule required awsRoleArn=\"" + accessGrantRoleArn + "\" awsRoleAccessKeyId=\"" + iamUserAccessKey + "\" awsRoleSecretAccessKey=\"" + iamUserSecretKey + "\" awsRoleExternalId=\"" + accessGrantExternalId + "\" awsRoleSessionName=\"" + producerSessionName + "\" awsStsRegion=\"" + regions.getName() + "\";"

Thanks and Best Regards,

#Let's Data

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

No branches or pull requests

1 participant