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

http-x-api-key auth not compatible with api gateway #327

Closed
donocode opened this issue Mar 26, 2020 · 3 comments · Fixed by #330
Closed

http-x-api-key auth not compatible with api gateway #327

donocode opened this issue Mar 26, 2020 · 3 comments · Fixed by #330

Comments

@donocode
Copy link

In the code for the converter it states that it is compatible with api gateway api key authorization but it does not seem to be the case or at least with the open api definition generated it does not correctly set the ApiKeyRequired property on the api gateway methods.

From my findings the security scheme that is generated looks like this:

"http-x-api-key": {
  "type": "apiKey",
  "description": "X-Api-Key authentication",
  "name": "X-Api-Key",
  "in": "header"
}

Which api gateway ignores, however if changing the value of name to x-api-key then api gateway will correctly set the ApiKeyRequired property on any methods annotated with @auth(["http-x-api-key"])

The other thing is that it should set X-Api-Key as an allowed header when using the @cors() trait but it does not (though it could be easily added by modifying the converter above)

Am I misinterpreting how this should work or is this a bug in the converter (or api gateway)?

@mtdowling
Copy link
Member

It's really weird that the "name" property is case sensitive in API Gateway. That seems like a bug. We can hack in a fix though for 0.9.x.

As for the CORs issue, here's a fix for the next major version we release (1.0): #328

mtdowling added a commit that referenced this issue Mar 27, 2020
Ensures that http-x-api-key adds the appropriate CORS headers and that
it uses the lowercase header name to make API Gateway happy.

Closes #327
@mtdowling
Copy link
Member

This should be fixed in 0.9.x via #330, and in 0.10 via #328 + ensuring that the customer header used is lowercase.

mtdowling added a commit that referenced this issue Mar 27, 2020
Ensures that http-x-api-key adds the appropriate CORS headers and that
it uses the lowercase header name to make API Gateway happy.

Closes #327
@donocode
Copy link
Author

Thanks for the quick turnaround!

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 a pull request may close this issue.

2 participants