简体   繁体   English

Boto3 - 使用Amazon Cognito进行身份验证而不使用访问密钥

[英]Boto3 - Authenticating with Amazon Cognito without using access keys

I'm developing a python script that interacts with a web service that uses Amazon Cognito (with which I'm unfamiliar) as the authentication backend and I'm having difficulties logging in. 我正在开发一个python脚本,它与使用Amazon Cognito(我不熟悉)的Web服务进行交互,作为身份验证后端,我在登录时遇到了困难。

My main issue is that boto3 requires both the AWS access key and secret key (without providing those I get the "NoCredentialsError"), but since this script will reside on multiple untrusted computers I don't want to store/embed those keys, for obvious security reasons. 我的主要问题是boto3需要AWS访问密钥和密钥(不提供我得到的“NoCredentialsError”),但由于此脚本将驻留在多个不受信任的计算机上,我不想存储/嵌入这些密钥,因为明显的安全原因。

The information that these untrusted computers will have access to are: 这些不受信任的计算机可以访问的信息是:

  • Username and Password for logging into the web service 用于登录Web服务的用户名和密码
  • Cognito Identity Pool ID Cognito身份池ID
  • Cognito User Pool ID Cognito用户池ID
  • Cognito Client ID Cognito客户端ID

Is it possible, with the informations these clients have, to correctly authenticate with Cognito? 通过这些客户端的信息,是否可以使用Cognito正确进行身份验证? If so, how? 如果是这样,怎么样?

Yes. 是。 Call get_credentials_for_identity() . 调用get_credentials_for_identity() It does not require any credentials. 它不需要任何凭据。 Use this as follows: 使用如下:

import boto3
cognito = boto3.client('cognito-identity')
response = cognito.get_credentials_for_identity(IdentityId="id")

where "id" is the Cognito Identity Pool ID. 其中"id"是Cognito Identity Pool ID。 response should return a dict including temporary Access Key, Secret Access Key, Session Token, and Expiration date. response应返回包括临时访问密钥,秘密访问密钥,会话令牌和到期日期的dict

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Python中使用Boto3在Amazon-Cognito中创建用户 - How to create user in amazon-cognito using boto3 in python 我们如何在不使用秘密访问密钥的情况下使用带有 IAM 角色的 boto3 连接到 Amazon CloudWatch - How can we connect to Amazon CloudWatch using boto3 with IAM role without using secret access key 如何使用boto3从名称中使用句点(。)来访问存储桶中的密钥? - How to access keys from buckets with periods (.) in their names using boto3? DEVICE_PASSWORD_VERIFIER 在 Amazon Cognito 中使用 boto3 和 warrant 的质询响应 - DEVICE_PASSWORD_VERIFIER challenge response in Amazon Cognito using boto3 and warrant 在 RDS 上使用 Boto3 与亚马逊 Aurora 交互 - Using Boto3 to interact with amazon Aurora on RDS 在Python Boto3中将AWS Cognito Identity与OpenID Salesforce结合使用 - Using AWS cognito Identity with openID salesforce in python boto3 如何使用 boto3 为 AWS Cognito 创建 SECRET_HASH? - How to create a SECRET_HASH for AWS Cognito using boto3? 如何使用AWS Cognito-身份池检索正确的凭证以在boto3客户端上访问AWS SecretsManger - How can I retrieve correct credentials to access AWS SecretsManger on a boto3 client using AWS Cognito - Indentity Pool 在不使用 boto3 的情况下改变 DynamoDB 中的表 - Mutate table in DynamoDB without using boto3 Amazon AWS Cognito和Python Boto3建立AWS连接并将文件上传到Bucket - Amazon AWS Cognito and Python Boto3 to establish AWS connection and upload file to Bucket
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM