-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Claims from authorizer lost in deserialisation and not mapped to HttpContext.User #98
Comments
Any updates on this, I have just experienced the same limitation. Having the apiGatewayRequest.RequestContext.Authorizer as a dictionary would be a great solution. |
As a workaround until there's an official solution, I've written this https://www.nuget.org/packages/MhLabs.Lambda.ApiGatewayAuthorizer/1.0.1 https://github.com/mhlabs/MhLabs.Lambda.ApiGatewayAuthorizer |
Also running into this. Would love a fix! |
I am also hitting this issue, Any idea on when a fix might become available? |
If somebody could send me a sample request that would speed up my time to getting this implemented. To send a sample request add the environment variable |
Hi I added this but it didnt give me much info, you can get the raw request by taking the input as a Stream
The full request is quite big but the data that is missing looks like this.
It is possible to deserialize the object to the classes below using JsonConvert as a work around
|
…equest to be serialized into APIGatewayCustomAuthorizerContext. If there are claims create ClaimsPrincipal for the HttpContext.User with the claims for the AspNetCoreServer This address GitHub issue #98
As part of the .NET Core 2.0 Lambda release today I updated I'm going to close this as I believe that solves the problem. Feel free to reopen or open a new issue if there are more use cases that are not met. |
@normj Thanks for this. I think it is a great addition that we can now use In particular, when doing a custom authorizer, we can return an However, looking at
... which are now marked obsolete in I guess the |
@normj, yeah, that looks right. At the moment we serialize our custom context into the It could be nice though if we could send through Claims and see them getting picked up by the new |
With #159 resolved, we can now add a key-val pair to |
Hi, I am a new bee to API Gateway and Lambda. I am trying to get the authorized user from my custom authorizer that returns user object. After enabling APIGatewayProxyRequest logging (LAMBDA_NET_SERIALIZER_DEBUG) I can see my user object getting logged in cloudwatch but when I am serializing the request in my lambda the authorizer section is empty. Lambda Deserialize Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest: My Lambda: "Authorizer": {} I highly appreciate your help. |
@normj : I think I'm missing something. I have a CustomAuthorizer returning a valid policy (taken from the blueprint). I want my underlying Lambda service to be able to access the PrincipalId, ideally in the HttpContext.User object. It looks as if this is only set when Claims are present in the request? I'm missing how to add Claims in my custom Authorizer? I'm returning a policy statement that looks like this: |
@normj : I have a rather connected question, and decided not to open another thread. What you've done with the APIGatewayProxyRequest is great, but do you have any plans for APIGatewayCustomAuthorizerContextOutput and more specific - allowing the values to be something more than a string value. In general the class is a Dictionary<string, object>, but according to the https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html - The returned values are all stringified. Notice that you cannot set a JSON object or array as a valid value of any key in the context map. This is kind of frustrating, because you can't send back an array of claims from the authorizer, and then pass them to the lambda you want to execute. Of course there are ways to put all the claims in the response, but then we are loosing the purpose of the change you made for the ClaimsIdentity and the HttpContext.User. Am I missing something, or my assumption is right? |
In
APIGatewayProxyFunction.FunctionHandlerAsync
where therequestStream
gets deserialised intoAPIGatewayProxyRequest
we lose all custom claims that were present in therequestStream
's json.It'd be nice if
apiGatewayRequest.RequestContext.Authorizer
would contain aDictionary<string,string>
with claims which get added toHttpContext.User
.Thanks,
Lars
The text was updated successfully, but these errors were encountered: