[英]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.