简体   繁体   English

AmazonCognitoIdentityProviderException:用户无权对资源执行 cognito-idp:DescribeUserPool

[英]AmazonCognitoIdentityProviderException: User is not authorized to perform cognito-idp:DescribeUserPool on resource

I am learning integrating AWS with an ASP .NET Core site.我正在学习将 AWS 与 ASP .NET 核心站点集成。 I am using AWS Cognito as a user store.我使用 AWS Cognito 作为用户存储。 I have created a sign-up form which actually acts as an interface to AWS Cognito.我创建了一个注册表单,它实际上充当了 AWS Cognito 的接口。 So far I have done the following steps:到目前为止,我已经完成了以下步骤:

  1. Created an User Pool in AWS Cognito.在 AWS Cognito 中创建了一个用户池。

  2. Created an User in IAM service.在 IAM 服务中创建了一个用户。 Attached the existing policy "AmazonCognitoDeveloperAuthenticatedIdentities" to this User.将现有策略“AmazonCognitoDeveloperAuthenticatedIdentities”附加到此用户。

  3. Created a credentials file in Windows in the user profile directory.在用户配置文件目录的 Windows 中创建了一个凭证文件。 Set the aws_access_key_id and aws_secret_access_key in this file在此文件中设置 aws_access_key_id 和 aws_secret_access_key

  4. In the appsettings.json file created an AWS section and set keys as below (I have hidden the User Pool Client Secret):在 appsettings.json 文件中创建了一个 AWS 部分并设置密钥如下(我隐藏了用户池客户端密码):

     "AWS": { "Region": "us-east-2", "UserPoolClientId": "44m80ksabq0knieeg81ina2npj", "UserPoolClientSecret": XXXXXX, "UserPoolId": "us-east-2_115WHTcaH" }
  5. I have imported the Amazon.AspNetCore.Identity.Cognito and Amazon.Extensions.CognitoAuthentication nuget packages.我已经导入了 Amazon.AspNetCore.Identity.Cognito 和 Amazon.Extensions.CognitoAuthentication nuget 包。 Using these packages, I have passed CognitoUser as the T parameter to the SignInManager and UserManager of ASP .NET Core Identity classes.使用这些包,我已将 CognitoUser 作为 T 参数传递给 ASP .NET Core Identity 类的 SignInManager 和 UserManager。 Below is the entire code of the controller.下面是 controller 的完整代码。

     public class Accounts: Controller { SignInManager<CognitoUser> _signInManager; UserManager<CognitoUser> _userManager; CognitoUserPool _pool; public Accounts(SignInManager<CognitoUser> signInManager, UserManager<CognitoUser> userManager, CognitoUserPool pool) { _signInManager = signInManager; _userManager = userManager; _pool = pool; } [HttpPost] public async Task<IActionResult> SignUp(SignupModel model) { if (ModelState.IsValid) { var user = _pool.GetUser(model.Email); if (user.Status.= null) { ModelState,AddModelError("UserExists"; "User with this email already exists"); return View(model). } user.Attributes.Add(CognitoAttribute.Name,AttributeName. model;Email). var createdUser = await _userManager,CreateAsync(user. model;Password). if (createdUser;Succeeded) { RedirectToAction("Confirm"); } } return View(); } }

When I execute this code, I get an error when trying to create an user (await _userManager.CreateAsync(user, model.Password)) as当我执行此代码时,尝试创建用户时出现错误 (await _userManager.CreateAsync(user, model.Password))

AmazonCognitoIdentityProviderException: User: arn:aws:iam::777844316068:user/xxxx is not authorized to perform: cognito-idp:DescribeUserPool on resource: arn:aws:cognito-idp:us-east-2:777844316068:userpool/us-east-2_115WHTcaH

I know this has to do with the Policy at IAM but I am not able to figure out the exact setting I am missing.我知道这与 IAM 的政策有关,但我无法弄清楚我缺少的确切设置。 Can someone help?有人可以帮忙吗?

Your user is not an administrator add to IAM uesrs permissions AdministratorAccess您的用户不是管理员添加到 IAM uesrs 权限 AdministratorAccess

Go to IAM users, select user, click "add inline policy", find a service "Cognito User Pools", search the action "DescribeUserPool", add user pool arn, create a policy Go 到 IAM 用户,select 用户,单击“添加内联策略”,找到服务“Cognito 用户池”,搜索“DescribeUserPool”操作,添加用户池 arn,创建策略

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

相关问题 用户无权执行:ses:VerifyEmailAddress - User is not authorized to perform: ses:VerifyEmailAddress Facebook错误(#200)用户未授权应用程序执行此操作 - Facebook Error (#200) The user hasn't authorized the application to perform this action WinForms应用程序中的“用户未授权应用程序执行此操作” - “The user hasn't authorized the application to perform this action” in WinForms app 窗口电话-用户未授权应用程序执行此操作? - window phone - The user hasn't authorized the application to perform this action? facebook c# sdk - 用户尚未授权应用程序执行此操作 - facebook c# sdk - The user hasn't authorized the application to perform this action C#Facebook API-用户未授权应用程序执行此操作 - C# Facebook API - The user hasn't authorized the application to perform this action 如何获取已认证用户的访问令牌以进行授权的资源api调用? - How to get access token for authenticated user to make an authorized resource api call? 此请求无权执行此操作。 Azure blobClient - This request is not authorized to perform this operation. Azure blobClient 检查用户是否在Orchard CMS中获得授权 - Checking if user authorized in Orchard CMS 如果用户未经授权,则返回较少的数据 - Return less data if user is not authorized
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM