Kuadrant / wasm-shim

A Proxy-Wasm module allowing communication to Authorino and Limitador.
Apache License 2.0
5 stars 5 forks source link

External Auth ~ish #92

Closed didierofrivia closed 1 month ago

didierofrivia commented 1 month ago

This huge PR addresses part of https://github.com/Kuadrant/wasm-shim/issues/58 ... However, all the previous PRs pointing to this branch were thoroughly reviewed (?).

Even if we are only certifying that Rate Limiting works, it's prepared for Auth too. We will close the issue when we provide documentation and deliver it along proper integration tests

List of the main PRs:

Config example

---
extensions:
  limitador:
    type: ratelimit
    endpoint: limitador-cluster
    failureMode: deny
policies:
  - name: rlp-ns-A/rlp-name-A
    hostnames:
      - '*.toystore.com'
      - example.com
    rules:
     - conditions:
          - allOf:
              - selector: request.path
                operator: eq
                value: /admin/toy
              - selector: request.method
                operator: eq
                value: POST
              - selector: request.host
                operator: eq
                value: cars.toystore.com
      actions:
        - extension: limitador
          scope: rlp-ns-A/rlp-name-A
          data:
            - static:
                key: rlp-ns-A/rlp-name-A
                value: "1"
            - selector:
                selector: auth.metadata.username

Verification:

Use the new guide in the README to verify multi-action setup:

make build && make local-setup

Port-forward envoy and watch the logs for all services:

kubectl port-forward --namespace default deployment/envoy 8000:8000
kubectl logs -f deployment/envoy
kubectl logs -f deployment/authorino
kubectl logs -f deployment/limitador

Test the authenticated rate limiting:

curl -H "Host: test.a.multi.com" http://127.0.0.1:8000/get -i
# HTTP/1.1 401 Unauthorized

Alice has 5 requests per 10 seconds:

while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: APIKEY IAMALICE" -H "Host: test.a.multi.com" http://127.0.0.1:8000/get | grep -E --color "\b(429)\b|$"; sleep 1; done

Bob has 2 requests per 10 seconds:

while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: APIKEY IAMBOB" -H "Host: test.a.multi.com" http://127.0.0.1:8000/get | grep -E --color "\b(429)\b|$"; sleep 1; done
gitguardian[bot] commented 1 month ago

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [13357796](https://dashboard.gitguardian.com/workspace/3149/incidents/13357796?occurrence=165668464) | Triggered | Generic High Entropy Secret | 8dd4c97df6b862a2bdbdcc4d4b31252ec3009e7e | utils/deploy/authconfig.yaml | [View secret](https://github.com/Kuadrant/wasm-shim/commit/8dd4c97df6b862a2bdbdcc4d4b31252ec3009e7e#diff-5f48823ac43842331d6496d44267113b3ae9e36a324c345031e7403d252db499R27) | | [13357796](https://dashboard.gitguardian.com/workspace/3149/incidents/13357796?occurrence=165846020) | Triggered | Generic High Entropy Secret | 40ce002c6ffbe8884a59a6b637633303e7ed4623 | utils/deploy/authconfig.yaml | [View secret](https://github.com/Kuadrant/wasm-shim/commit/40ce002c6ffbe8884a59a6b637633303e7ed4623#diff-5f48823ac43842331d6496d44267113b3ae9e36a324c345031e7403d252db499R27) | | [13357796](https://dashboard.gitguardian.com/workspace/3149/incidents/13357796?occurrence=166222888) | Triggered | Generic High Entropy Secret | 91da4439005653b4351b434d6a8a816886035219 | utils/deploy/authconfig.yaml | [View secret](https://github.com/Kuadrant/wasm-shim/commit/91da4439005653b4351b434d6a8a816886035219#diff-5f48823ac43842331d6496d44267113b3ae9e36a324c345031e7403d252db499L27) | | [13357796](https://dashboard.gitguardian.com/workspace/3149/incidents/13357796?occurrence=166577404) | Triggered | Generic High Entropy Secret | 88cb14baaabf3853182a76de43ba2a70fc02deff | utils/deploy/authconfig.yaml | [View secret](https://github.com/Kuadrant/wasm-shim/commit/88cb14baaabf3853182a76de43ba2a70fc02deff#diff-5f48823ac43842331d6496d44267113b3ae9e36a324c345031e7403d252db499L27) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secrets safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate these secrets](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/generic_high_entropy_secret#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

eguzki commented 1 month ago

Have you considered in squashing commits? Is it worth 72 commits? Up to you.