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

fix: Support httpApi authorizer with different config and function names #1763

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

adamldoyle
Copy link

@adamldoyle adamldoyle commented Feb 27, 2024

Description

httpApi authorizer's have their config in the provider section with a name that can be used by httpApi events to attach that authorizer. The authorizer's underlying function is separately defined and is allowed to have a different name than the authorizer config in the provider section. The current implementation by serverless-offline requires that both of those names are the same. This PR fixes this issue by embedding all of the provider config and setting the function name to the one defined in the config.

Motivation and Context

Fixes #1624

How Has This Been Tested?

Manually tested with a small sample app that reproduced the initial issue. Updated existing integration tests that weren't actually using the correct authorizer names (they were using the function names). Added new integration test to reference an authorizer based on config name and have it point to a function name with a different name.

Screenshots (if appropriate):

N/A

@@ -326,7 +342,7 @@ export default class HttpServer {
? serverlessAuthorizerOptions?.payloadVersion || "2.0"
: "1.0",
resultTtlInSeconds:
serverlessAuthorizerOptions?.resultTtlInSeconds || "300",
serverlessAuthorizerOptions?.resultTtlInSeconds ?? "300",
Copy link
Author

Choose a reason for hiding this comment

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

Originally I was copying more of the config from serverlessAuthorizerOptions but I un-did that to simplify the logic. However, this needed to be changed in order to allow 0 to be set for resultTtlInSeconds inside the provider config.

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.

httpApi custom authorizer does not work by the docs
1 participant