Authorizer context not passed to lambda function for SimpleResponse authorizer
See original GitHub issueAre you certain it’s a bug?
- Yes, it looks like a bug
Is the issue caused by a plugin?
- It is not a plugin issue
Are you using the latest version?
- Yes, I’m using the latest version
Is there an existing issue for this?
- I have searched existing issues, it hasn’t been reported yet
Issue description
I set up a simple response authorizer like so:
provider:
...
httpApi:
authorizers:
verify_token:
type: request
functionName: verify_token
resultTtlInSeconds: 300
enableSimpleResponses: true
payloadVersion: '2.0'
identitySource:
- $request.header.Authorization
and return a context in my authorizer like so:
let authResult = {
"isAuthorized": true,
"context": {
"email": decoded.email,
"user_id": decoded.user_id,
}
};
return callback(null, authResult);
However, the context is not getting passed into my lambda function. I saw that this was supposed to be addressed here: https://github.com/serverless/serverless/pull/4773 but perhaps that only works for authorizers with Policy responses and not simple responses?
Service configuration (serverless.yml) content
provider:
...
httpApi:
authorizers:
verify_token:
type: request
functionName: verify_token
resultTtlInSeconds: 300
enableSimpleResponses: true
payloadVersion: '2.0'
identitySource:
- $request.header.Authorization
functions:
verify_token:
handler: auth.verify_token
update_contacts:
handler: contacts.update_contacts
events:
- httpApi:
path: /users/update_contacts
method: post
authorizer: verify_token
Command name and used flags
N/A
Command output
N/A
Environment information
Framework Core: 2.70.0 (local)
Plugin: 5.5.2
SDK: 4.3.0
Components: 3.18.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Output from an Amazon API Gateway Lambda authorizer
A Lambda authorizer function's output is a dictionary-like object, which must include the principal identifier ( principalId ) and a policy document ...
Read more >Lambda Authorizer Context Response Size Limit | AWS re:Post
I've implemented a lambda authorizer for an HTTP API using the simple response format and it works great. I am passing some extra...
Read more >Lambda Authorizer | Simple response mode | HTTP API
Welcome to part 12 of the new tutorial series on Amazon HTTP API. In this video, we will cover how to configure Lambda...
Read more >Secure your API Gateway APIs with Lambda Authorizer
Why would we like to use custom Lambda baked Authorizer and not any of the ... In the Lambda function the context data...
Read more >Implementing Typescript for AWS Authoriser Lambda with ...
ApiGateway v2 (aka HTTP API); Authorizer Lambda with payload v2 ... + authorizer v2 with simple response + our very own "context "...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jega-ms I don’t think that simple responses are even supported by serverless-offline. I’ve just created this issue in serverless-offline repo https://github.com/dherault/serverless-offline/issues/1475
Hey @jega-ms - it seems like something specific to
serverless-offline
plugin so you might need to consult the features that are supported on that plugin side and report potential issues there.