java - AWS API Gateway custom authorizer. How to access principalId in lambda -
so trying set custom authorizer in api gateway.
i can forward request valid token lambda function specified in api method. cannot figure out how access principalid passed on authorizer though.
when executing request following in cloud watch log:
authorizer result body before parsing: { "principalid": "16", "policydocument": { "version": "2012-10-17", "statement": [ { "condition": {}, "action": "execute-api:invoke", "resource": [ "arn:aws:execute-api:eu-central-1:****:***/null/*/*" ], "effect": "allow" }, { "condition": {}, "action": "execute-api:invoke", "resource": [], "effect": "deny" } ] } }
so how access principalid in lambda function? object passed on lambda? , if not, how @ least principalid passed?
the principalid can (and default is) forwarded lambda implementation. depending on mapping, principalid should appear in context variable.
you can access principalid value in mapping template using $context.authorizer.principalid variable. useful if want pass value backend. more information, see accessing $context variable.
Comments
Post a Comment