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

enable api keys for query endpoints #527

Merged
merged 4 commits into from
May 23, 2024
Merged

Conversation

solomon-negusse
Copy link
Member

@solomon-negusse solomon-negusse commented May 23, 2024

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Check the commit's or even all commits' message styles matches our requested structure.
  • Check your code additions will fail neither code linting checks nor unit test.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

query endpoints are not protected with api key

What is the new behavior?

query endpoints protected and rate limits enabled..

Does this introduce a breaking change?

  • Yes
  • No

Other information

Copy link
Collaborator

@danscales danscales left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for doing this!

@@ -52,13 +52,13 @@ variable "api_gateway_usage_plans" {
default = {
internal_apps = {
quota_limit = 10000 # per day
burst_limit = 100 # per second
rate_limit = 200
burst_limit = 300
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe increase quota_limit and burst_limit even more (50000/1000)? Kinshuk said we need high limits for processing of large lists - there could be a lot of requests if a customer creates a new large lists with 25000 locations.

Copy link
Member Author

Choose a reason for hiding this comment

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

@danscales: adding this to develop branch, merged before adding.

api_key, payload = apikey
origin = "https://" + payload["domains"][0]
headers = {"origin": origin, "x-api-key": api_key}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to make a single function get_header that replaces these three lines everywhere with headers = get_header(apikey)

@@ -73,7 +73,7 @@ module "query_post" {
authorizer_id = aws_api_gateway_authorizer.api_key.id
api_resource = module.query_resource.aws_api_gateway_resource

require_api_key = false
require_api_key = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see a terraform module here for zonal statistics, similar to these 'query_post' and 'query_get' modules. Do we need a terraform module for zonal statistics as well to actually enable rate limiting for zona statistics?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, that's a deprecated endpoint and not used much looking at the usage stats. How about I merge this and address that in future iteration.

@solomon-negusse solomon-negusse merged commit 9fc25e8 into develop May 23, 2024
2 checks passed
@solomon-negusse solomon-negusse deleted the enable-query-api-key branch May 23, 2024 15:50
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.

3 participants