简体   繁体   English

aws - 是否可以在 lambda function 中使用 Cognito 用户池自定义字段?

[英]aws - is it possible to use Cognito user pool custom field in lambda function?

I have created a custom field "permissions" in my user pool.我在我的用户池中创建了一个自定义字段“权限”。
在此处输入图像描述 在此处输入图像描述

I wonder if it is possible to use this field in my lambda function, so that I can do some permission control for calling the corresponding lambda function. I wonder if it is possible to use this field in my lambda function, so that I can do some permission control for calling the corresponding lambda function.

For example例如

if((**custom.permissions**).includes("admin")){
   // execute the lambda function
}

For example if your lambda function was written using python boto3 you can get the user Attributes like this:例如,如果您的 lambda function 是使用 python boto3 编写的,您可以获得如下用户属性:

import boto3

client = boto3.client('cognito-idp')

response = client.get_user(
    AccessToken='string'
)

The response structure contains UserAttributes (list) -- An array of name-value pairs representing user attributes.响应结构包含 UserAttributes (list) -- 表示用户属性的名称-值对数组。

For custom attributes, you must prepend the custom: prefix to the attribute name.对于自定义属性,您必须在属性名称前添加 custom: 前缀。

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

相关问题 在 AWS Cognito 用户池中删除用户时触发 Lambda 函数 - Triggering a Lambda function upon deleting a user on AWS Cognito User Pool Cognito用户池触发器上的AWS Lambda错误 - AWS Lambda error on Cognito User Pool trigger 在 Lambda 函数中获取 Cognito 用户池身份 - Get Cognito user pool identity in Lambda function AWS Lambda-如何使用context.identity.cognitoIdentityId获取相关的Cognito用户池用户数据? - AWS Lambda - How to use context.identity.cognitoIdentityId to get related Cognito User Pool user data? 如何将用户从AWS Lambda添加到Cognito用户池组? - How to add a user to a Cognito User Pool Group from AWS Lambda? 是否可以使用/连接 AWS Cognito 用户池到 AWS SFTP 服务器访问 - is it possible to use/connect AWS Cognito user pool to AWS SFTP Server access AWS cognito用户池,自定义消息lambda - AWS cognito user pools, custom message lambda lambda 中的 AWS Cognito 用户池 AdminCreateUser 不返回错误也不返回数据 - AWS Cognito User Pool AdminCreateUser in lambda returns no error nor data AWS Cognito&Lambda:将联合身份添加到用户池 - AWS Cognito & Lambda: add federated identity to user pool 使用认知用户池将 userId 从 angular 传递到 aws lambda - Passing userId from angular using cognito user pool to aws lambda
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM