首页 > 解决方案 > 在没有 cognito 的情况下访问 android 中的 aws 私有存储桶

问题描述

我是使用 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 或自定义代码可以帮助我访问所有用户的整个私有存储桶,而无需进行身份验证?

标签: androidamazon-web-servicesamazon-s3aws-amplifyaws-amplify-sdk-android

解决方案


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

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

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

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


推荐阅读