Having worked extensively with Node.js in the past, we are currently investigating ASP.NET Core as an alternative Lambda platform.
In the past, our API Gateway-fronted s
We've in the exact same situation and I can by no means offer a nice and clean solution, but I have a workaround.
If you look at the request payload, the json is formatted like this:
{
[...]
"requestContext": {
[...]
"authorizer": {
"claims": {
"claim1": "value1",
"claim2": "value2",
"claim3": "value3",
}
},
[...]
In APIGatewayProxyFunction.FunctionHandlerAsync
they deserialize the requestStream
into an APIGatewayProxyRequest
. If you step into that class you'll find that the Authorizer part of the json gets deserialized into:
public class APIGatewayCustomAuthorizerContext
{
public string PrincipalId { get; set; }
public string StringKey { get; set; }
public int? NumKey { get; set; }
public bool? BoolKey { get; set; }
}
I.e all claims are lost in deserialization. I've posted this issue here: https://github.com/aws/aws-lambda-dotnet/issues/98
Now to the workaround, I've just put something that "works" together here (Code here):
Note that it's very untested. :-)
Usage:
public class LambdaEntryPoint : APIGatewayAuthorizerProxyFunction
{
protected override void Init(IWebHostBuilder builder)
{
builder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseApiGateway();
}
}