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

RequestContext.Authorizer differs between REST gateway vs HTTP gateway #5148

Closed
alexanderwink opened this issue Jan 21, 2024 · 2 comments
Closed
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@alexanderwink
Copy link

Describe the bug

Transitioning from REST gateway to HTTP gateway (v1)

My authorizer end with something like this:

authResponse.Context = map[string]interface{}{ "field1": fieldvalue1, "field2": fieldvalue2, }

When using REST gateway I can get the authorizer context by the RequestContext.Authorizer map which is a map[string]interface{}

But when using HTTP gateway the RequestContext.Authorizer map does not look the same.

Here is a printout from the logs

REST gateway
map[field1: fieldvalue1 field2: fieldvalue2]

HTTP gateway
map[lambda:map[[dbName:treks_dev userId:11](field1: fieldvalue1 field2: fieldvalue2)]]

This makes transitioning from REST to HTTP gateway cumbersome since it requires code changes in all functions that use the autorizer.

Expected Behavior

I expect the response (v1) from HTTP gateway to be identical to the response from the REST gateway so that changing from REST to HTTP gateway is possible without code changes to the functions.

Current Behavior

HTTP gateway response has an extra level of map[string]interface{} within the Context map. It does not look like this was intended.

Reproduction Steps

Any authorizer that returns a context. Access the authorizer context in a function (REST gateway) like this:
context := request.RequestContext.Authorizer field1 := context["field1"].(string)

Change to HTTP gateway and the second line will cause a NPE since there a map in a map in this case and field1 is only available in the inner map.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v1.44.0

Environment details (Version of Go (go version)? OS name and version, etc.)

go version go1.21.6, running on AWS provided.al2

@alexanderwink alexanderwink added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 21, 2024
@alexanderwink alexanderwink closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@alexanderwink
Copy link
Author

Sorry this should have been posted at aws/aws-lambda-go#549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant