AMAZON_COGNITO_USER_POOLS authorization
。Boto3
AppSync 客户端与 evaluate_mapping_template
或 evaluate_code
功能结合使用。如果我通过以下上下文:
context = {
"arguments": {},
"stash": {},
"source": {},
"result": {},
"identity": {"username": "user"},
"request": {},
}
对于最基本的解析器,它只返回
ctx.identity.username
。
响应包含错误:
'error': {'message': 'Unrecognized field "username" (class com.amazonaws.deepdish.common.identity.LambdaAuthIdentity), not marked as ignorable (one known property: "resolverContext"])\n at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.amazonaws.deepdish.transform.model.MappingTemplateContext$MappingTemplateContextBuilder["identity"]->com.amazonaws.deepdish.common.identity.LambdaAuthIdentity["username"])'}
看起来它只使用了
AWS_LAMBDA authorization
,来自文档:
身份具有以下形式:
type AppSyncIdentityLambda = { resolverContext: any; };
我看不出如何指定应使用哪种类型的授权类型进行评估。
我尝试根据问题描述更改解析器的内容并简化上下文。我在文档中找不到任何有关它的信息,并且有在线示例,它说它应该可以工作。
提前致谢。
似乎
identity
对象需要包含所有必填字段(未记录)。
我能够通过严格遵循官方文档来解决该问题:https://docs.aws.amazon.com/appsync/latest/devguide/test-debug-resolvers-js.html
示例身份对象如下所示:
identity: {
sub : "uuid",
issuer : " https://cognito-idp.{region}.amazonaws.com/{userPoolId}",
username : "Nadia",
claims : { },
sourceIp :[ "x.x.x.x" ],
defaultAuthStrategy : "ALLOW",
}