3

我是使用 aws 的新手,但遇到了一些麻烦。我有一组视频存在于aws s3 bucket. 我正在创建一个 android 应用程序,它将读取存储桶的视频,将它们显示为列表并允许用户流式传输这些视频。

问题是我的应用程序使用非 aws 独立服务器进行身份验证,因此我不想使用aws-cognito身份验证。当我尝试为 s3 搜索本机 sdk 时,我被指向了aws-amplify框架,当我尝试按照此处的文档进行操作时,我陷入了强制设置 cognito 身份验证的这一步。

? You need to add auth (Amazon Cognito) to your project in order to add storage for user files. Do you want to add auth now?
    `Yes` // <------------------------ this is for either now or later, can't say no to adding auth at all   

? Do you want to use the default authentication and security configuration?
    `Default configuration` //<-------------------------------------- can't say no here

? How do you want users to be able to sign in?
    `Username`

? Do you want to configure advanced settings?
    `No, I am done.`

? Please provide a friendly name for your resource that will be used to label this category in the project:
    `S3friendlyName`

? Please provide bucket name:
    `storagebucketname`

? Who should have access:
    `Auth and guest users`

? What kind of access do you want for Authenticated users?
    `create/update, read, delete`

? What kind of access do you want for Guest users?
    `create/update, read, delete`

? Do you want to add a Lambda Trigger for your S3 Bucket?
    `No`

我对此不确定,但我相信有一种方法可以仅使用iam用户访问密钥来访问一些私有存储桶数据。那么哪个 sdk 或自定义代码可以帮助我访问所有用户的整个私有存储桶,而无需进行身份验证?

4

2 回答 2

1

目前,AmplifyAWSS3StoragePlugin被硬编码为要求使用 Amazon Cognito 进行身份验证/授权。

如果您只想使用 IAM ,请在 Amplify Android GitHub 存储库上创建功能请求。

如果您想使用自己的凭证提供者进行身份验证,可以将 OpenID Connect 提供者与 Cognito 联合

选项是使用AWS SDK for Android 中的低级AmazonS3Client. 这将允许您提供自己的AWSCredentialsProvider. 提供凭证的有效方式有很多种。注意:AWSMobileClient是用于进行 Cognito 身份验证的实用程序,它是AWSS3StoragePlugin.

于 2020-08-28T04:27:20.320 回答
0

如果用户应该能够在无需身份验证的情况下访问存储桶,您可以使该存储桶中的对象可公开访问。这样,您就可以跳过访问私有存储桶所涉及的额外工作,以便轻松访问您想要轻松访问的对象(无身份验证)。

如果存储桶中的对象和存储桶本身必须保持私有,那么您可以遵循本指南:“Restricting Access to Amazon S3 Content by Using an Origin Access Identity for control access to S3 via CloudFront. Theory is that users won't能够访问您的 S3 内容,除非来自您的 OAI 配置的 CloudFront 分配。之后,您可以找到一种方法来访问您的 CloudFront 分配并仅使用您的应用程序从那里获取内容。

于 2020-08-22T22:57:46.513 回答