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: checking generated api key #1589

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,11 @@ export default class HttpServer {
const apiKey = createApiKey()

this.#apiKeysValues = getApiKeysValues(
this.#serverless.service.provider.apiGateway?.apiKeys ?? [apiKey],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work correctly. The result of this expression is that this.#apiKeysValues is an empty set which means the key that was just created will not work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, you are right. the problem is that we are passing the result of the expression to getApiKeysValues, which expects an array of objects, while [apiKey] is just an array of a string.

this.#serverless.service.provider.apiGateway?.apiKeys ?? [],
)

this.#apiKeysValues.push(apiKey)
Copy link
Collaborator

@dnalborczyk dnalborczyk Oct 1, 2022

Choose a reason for hiding this comment

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

getApiKeysValues is returning a Set, where push does not exist. we would need to use .add here. ideally we would only push when we have no values in the Set. and ideally we would only then call createApiKey.


log.notice(`Key with token: ${apiKey}`)
}
}
Expand Down