Skip to content
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

Add API Gateway V2 custom authorizer simple response type #386

Merged
merged 6 commits into from Sep 17, 2021

Conversation

dirknilius
Copy link
Contributor

Issue #369, #372:

Description of changes:

This PR adds the missing type for API Gateway V2 custom authorizer simple response. See: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html#http-api-lambda-authorizer.payload-format-response

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dirknilius dirknilius changed the title Add API Gateway V2 simple response type Add API Gateway V2 custom authorizer simple response type Aug 10, 2021
events/apigw.go Outdated
// APIGatewayV2CustomAuthorizerSimpleResponse represents the simple format of an API Gateway V2 authorization response.
type APIGatewayV2CustomAuthorizerSimpleResponse struct {
IsAuthorized bool `json:"isAuthorized"`
Context map[string]interface{} `json:"context"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get a chance to verify this works as expected with a context set and without it set (using the default value). I just wonder what happens if Context is nil (null in json) and/or an empty map ({} in json)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, already using it in production for a while. Works with or without context. So the API accepts the input. But I could check what’s exactly generated and if it makes sense to add omitempty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense and save just a few bytes over the long run so if you could check that would be great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @harrisonhjones, I just added the tests. Pls take a look if I covered everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I also added the omitempty flag, as the results are more reasonable.

@dirknilius dirknilius force-pushed the feature/http-api-v2-simple-response branch from 291457d to 13d994a Compare August 11, 2021 08:22
@dirknilius dirknilius force-pushed the feature/http-api-v2-simple-response branch from 13d994a to 6630aa2 Compare August 11, 2021 08:22
Copy link
Contributor

@harrisonhjones harrisonhjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

events/apigw_test.go Outdated Show resolved Hide resolved
events/apigw_test.go Show resolved Hide resolved
@harrisonhjones
Copy link
Contributor

@bmoffatt or someone else on the Lambda team would need to merge it in.

Copy link
Collaborator

@bmoffatt bmoffatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bmoffatt bmoffatt merged commit 9e2b352 into aws:master Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants