Code Monkey home page Code Monkey logo

chromadb-envoy-proxy-rate-limits's Introduction

Chroma Auth and Limits Demo

This repo demonstrates the following capabilities:

  • Static quotas enforcement with periodic quota refresh
  • Tiered quotas enforcement - quotas are enforced based on the user tier
  • Dynamic quotas enforcement with periodic quota refresh (do we need that one or can we rely on OPA/OPAL for that?)
  • AuthZ with KC and OPA/OPAL - fine-grained access control

Getting started

make build
docker compose up --build

Use cURL to send a request to the server:

curl -X POST --location "http://localhost:18000" \
    -H "Content-Type: application/json" \
    -d '{
          "embeddings": [
            [
              0.5,
              0.5
            ]
          ],
          "metadatas": [
            {
              "key1": "strting",
              "key2": "string1232222222222222222",
              "key3": 1,
              "key4": 1.1,
              "key5": true
            }
          ],
          "documents": [
            "document 1"
          ],
          "uris": null,
          "ids": [
            "doc-id-1"
          ]
        }'

Roadmap

  • Periodic refresh of static quotas - How can this be done with OPA and OPAL where quotas are stored as JSON in a repo?

Learnings about Envoy plugin development

  • Tinygo to be used to compile the plugin to WebAssembly
  • Plugin lifecycle is decoupled from request lifecycle
  • Plugin lifecycle can be used to communicate with external services for fetching data and updating
  • Plugin context can be injected in each request context
  • If you use internal direct_response listener filter than responses bypass the plugin and get returned instead of request waiting for plugin to finish (especially if external async call is made)

Request Authorization Sequence

  • Check headers - check if required headers are present. For example, API key, content type, etc.
  • Authz (API key validity) - check if the API key is valid and returns user identity which includes attributes and permissions
  • Static/Global Quotas - check if the user has exceeded his static quotas, like maxium number of documents per request, maximum number of fields, maximum length of a field, etc.
  • Dynamic Quotas - check if the user has exceeded his dynamic quotas, like overall storage, daily request limit etc.
  • Rate Limit (Global) -
  • Rate Limit (Tiered) - tiered/user specific rate limits
  • Authz Resource (Coarse-grained) - check if the user has access to the resource he is trying to access
  • Authz Resource (Fine-grained) - check if the user has access to the specific action he is trying to perform on the resource

References

Plugins:

Rate Limiting:

OPA/OPAL:

chromadb-envoy-proxy-rate-limits's People

Contributors

tazarov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.