-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
feat: httpApi with request authorizer #1600
feat: httpApi with request authorizer #1600
Conversation
thank you for the PR @rion18 ! |
I just deployed your serverless.yml from the test and it's throwing an error when deployed to aws and requested with your authorization token
|
After deploying this myself, I found my project to be under the same circumstances as It seems that no authorizer was implemented for an I've went on ahead and added support for payloadFormat 2.0, and payloadFormat 2.0 with simple responses enabled, for Integration tests have been added, this has been tested by deploying the small test app in AWS, as well as using this fork on a local project. I've also added support for I've made some cleanup inside the configureAuthorization function which was only deploying authorizers for |
@dnalborczyk Sorry for the delay, but I have some good news detailed above :) Let me know if something else is up. |
Tests are failing on |
@rion18 the tests can be a bit flaky sometimes. I restarted that one particular failure. I try to have a look at your PR later today. |
thank you @rion18 ! great work! |
Description
I've added a simple check on the
#configureJWTAuthorization
function to take care of a case that wasn't handled before: when the endpoint declares an authorizer with typerequest
, or when the authorizers inside ofprovider.httpApi
does so. This will prompt#setAuthorizationStrategy
to use#configureAuthorization
, instead of#configureJWTAuthorization
.Motivation and Context
This solves the problem of using local authorizers with serverless-offline. Starting the server when using
httpApi
events would ALWAYS assume that the local authorizers are of typejwt
. This adds support for therequest
type.This fixes issues:
resolves #1311
resolves #1343
How Has This Been Tested?
This has been tested using Mocha, creating a new set of integration tests called
request-authorizers
. Tests a scenario where the provider's httpApi has defined anauthorizers
property.This change should only affect the proposed scenario: when you want to run serverless-offline with a
request
type authorizer.Updates
This also fixes issues:
resolves #1341
resolves #1475
After doing some more integration testing, I discovered that
request
authorizers were not correctly implemented forhttpApi
events. So this also adds support for payloadFormat 2.0 as well as simpleResponses.This has been tested by adding upon the previous
request-authorizers
tests, where we define three configuration scenarios:httpApi
event with payloadFormat 1.0httpApi
event with payloadFormat 2.0httpApi
event with payloadFormat 2.0 with simple responses enabled. (Bear in mind that in order to test the newidentitySource
field as an array, these tests use theAuthorizationSimple
header instead ofAuthorization
.It's also been tested by deploying the integration test on AWS, as well as personal project, with success in all cases.