首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用STS JAVA SDK的AWS S3授权

使用STS JAVA SDK的AWS S3授权
EN

Stack Overflow用户
提问于 2021-05-14 20:02:24
回答 1查看 165关注 0票数 0

我有一个在EKS中运行的应用程序实例,设置了以下变量:

代码语言:javascript
复制
declare -x AWS_DEFAULT_REGION="us-west-2"
declare -x AWS_REGION="us-west-2"
declare -x AWS_ROLE_ARN="xxxxx"
declare -x AWS_WEB_IDENTITY_TOKEN_FILE="/var/run/secrets/eks.amazonaws.com/serviceaccount/token"

据我所知,有一个默认的Java SDK授权链,其中包含在幕后构建com.amazonaws.services.securitytoken.AWSSecurityTokenServicecom.amazonaws.auth.WebIdentityTokenCredentialsProvider

但是我不知道这种循环依赖是如何解决的?我的意思是,您需要在创建AWSSecurityTokenService时指定凭据,但凭据会创建服务本身。

我有这样做的实际需求,我想在sts客户端中自定义端点,但因为循环依赖而不能。

代码语言:javascript
复制
AWSSecurityTokenServiceClientBuilder.standard()
        .withCredentials(new STSAssumeRoleWithWebIdentitySessionCredentialsProvider.Builder(
                "arn",
                "session",
                "tokenfile")
                .withStsClient(xxxx)
                .build())
        .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:4566", null))
        .build()
EN

回答 1

Stack Overflow用户

发布于 2021-05-14 20:49:48

这很简单。它只是使用匿名身份验证(https://github.com/aws/aws-sdk-java/blob/1.11.792/aws-java-sdk-sts/src/main/java/com/amazonaws/auth/STSAssumeRoleWithWebIdentitySessionCredentialsProvider.java#L122-L125)完成的

代码语言:javascript
复制
        return AWSSecurityTokenServiceClientBuilder.standard()
                                                   .withClientConfiguration(clientConfiguration)
                                                   .withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
                                                   .build();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67534009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档