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

Per-route rate limiting #248

Open
Southclaws opened this issue Oct 19, 2024 · 0 comments
Open

Per-route rate limiting #248

Southclaws opened this issue Oct 19, 2024 · 0 comments

Comments

@Southclaws
Copy link
Owner

Basic across-the-board rate limiting is now in, but we definitely need some route-level rate limits. This can be accomplished by updating rbacgen (and probably renaming) to extract OpenAPI extension properties and using that to apply rate limits.

  /threads:
    post:
      x-storyden-ratelimit: 1000
      operationId: ThreadCreate
...

And in the codegen:

	for _, path := range docModel.Model.Paths.PathItems.FromOldest() {
		for _, op := range path.GetOperations().FromOldest() {
			ops = append(ops, Operation{
				Name: op.OperationId,
			})

			rateLimit, ok := op.Extensions.Get("x-storyden-ratelimit")
			// generate route middleware with this rate limit
		}
	}

I'm still not set on an exact rate limit algo so the meaning of the underlying value will be dependent on that.

Regarding rbacgen: it's mostly likely becoming a generic codegen extension for the Storyden spec, so it would make sense to rename this to reflect that.

Given that we can use x- properties for specifying properties on each route, it makes sense to bin the existing RBAC interface mapping and instead declare the permissions actually on the routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant