Skip to content

[public-api] add rate limiting in server #18953

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

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

akosyakov
Copy link
Member

@akosyakov akosyakov commented Oct 18, 2023

Description

This PR adds rate limiting to Public API in Server:

  • It is based on Redis.
  • Rate limits are enforced pet subject id + grpc_service + grpc_method
  • Rate limits are configured via RateLimited decorator but can be overridden with config map during operations.
Summary generated by Copilot

🤖 Generated by Copilot at 51fe912

This pull request refactors the server component to use JWT cookies for authentication and authorization, and implements rate limiting for the gRPC API using Redis and memory. It also migrates the public-api-workspaces-get command to use the gRPC API and updates the WorkspaceServiceAPI class to use the userId from the context.

Related Issue(s)

Fixes EXP-766

How to test

The preview env has gRPC api enabled from the dashboard plus rate limit is configured for getWorkspace as 1 call per a minute via a configmap.
Screenshot 2023-10-19 at 12 54 31

Open a dev tool, and start a workspace, in dev tools filter to getWorkspace calls. You should see 429 error codes, investigate headers (Retry-After + X-Ratelimit-*) for additional info about rate limiting. If you reload the page you should see that eventually it is successful.
Screenshot 2023-10-19 at 12 52 16

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@akosyakov akosyakov force-pushed the ak/public_api_rate_limit branch 6 times, most recently from 19553fa to debe4bc Compare October 19, 2023 10:07
@akosyakov akosyakov force-pushed the ak/public_api_rate_limit branch from debe4bc to 198ac2c Compare October 19, 2023 10:52
@akosyakov akosyakov marked this pull request as ready for review October 19, 2023 11:01
@akosyakov akosyakov requested a review from a team as a code owner October 19, 2023 11:01
@akosyakov
Copy link
Member Author

/unhold

@roboquat roboquat merged commit 01f100b into main Oct 19, 2023
@roboquat roboquat deleted the ak/public_api_rate_limit branch October 19, 2023 11:28
akosyakov added a commit that referenced this pull request Oct 19, 2023
roboquat pushed a commit that referenced this pull request Oct 19, 2023
* Revert "fix JWT verification (#18957)"

This reverts commit 90c3541.

* Revert "[public-api] add rate limiting in server (#18953)"

This reverts commit 01f100b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants