Skip to content

feat: new authentication scheme and upstream server whitlisting - #139

Merged
Prajna1999 merged 11 commits into
mainfrom
feat/auth-authz-with-backend
Sep 11, 2026
Merged

feat: new authentication scheme and upstream server whitlisting#139
Prajna1999 merged 11 commits into
mainfrom
feat/auth-authz-with-backend

Conversation

@Prajna1999

@Prajna1999 Prajna1999 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Target issue is #140

  • Change kaapi-guardrails to be internal-only, accepting requests solely from kaapi-backend.
    Each request should include a bearer token plus X-ORGANIZATION-ID/X-PROJECT-ID headers (set upstream).
  • Limit requests to IPs within ALLOWED_IPS.
  • Implement a check order: IP → token → tenant headers (respond with 403 → 401 → 422).

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

  • Coordinate deployment to ensure kaapi-backend sends new headers and removes X-API-KEY/body-tenant before or with guardrails deploy.
  • No support for X-Forwarded-For, token-rotation overlap window, or per-route permissions/CIDR/mTLS at this time.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: cd1bdd8f-cccc-4358-b948-1d7d69f9a80f

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/auth-authz-with-backend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Prajna1999
Prajna1999 marked this pull request as ready for review August 17, 2026 03:45
@Prajna1999 Prajna1999 self-assigned this Aug 17, 2026
@Prajna1999

Prajna1999 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

correct for today's direct-connection deployment, and the doc explicitly flags this breaks the moment a load balancer/reverse proxy sits in front (every request would then appear to come from the LB's IP, silently defeating the allowlist rather than failing loudly). [follow-up] Worth a monitoring/alert plan for "is this still a direct connection" before any infra change, since the failure mode . Note for self @Prajna1999

@Prajna1999

Prajna1999 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

For CI failure https://github.com/guardrails-ai/guardrails/blob/main/HUB_UPDATE.md and tl;dr: Guardrails validators are moving to standard PyPI packages you install directly with pip, and Guardrails is discontinuing its hosted remote inferencing. Fixed in stacked PR #152 to fix CI.

@Prajna1999 Prajna1999 linked an issue Sep 6, 2026 that may be closed by this pull request
@Prajna1999 Prajna1999 changed the title feat: limit auth deps to bearer token and ip allowlist feat: new authentication scheme and upstream server whitlisting Sep 6, 2026
Comment thread backend/README.md

3. In `backend/app/schemas/guardrail_config.py`, add the newly created config class to `ValidatorConfigItem`.

# test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this

#2. A JSON-encoded array string like '["1.2.3.4","5.6.7.8"]'
# (some env/deploy tooling JSON-encodes list-valued env vars) → parses it with json.loads.

def parse_ip_list(v: Any) -> list[str] | str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we fail at bootup if IP list is invalid instead of returning error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if ENV=production and ALLOWED_IPS="", guardrails will fail at boot up.

@Prajna1999
Prajna1999 force-pushed the feat/auth-authz-with-backend branch from 8d697aa to 27306d4 Compare September 11, 2026 09:08
@Prajna1999
Prajna1999 merged commit c3cbbaf into main Sep 11, 2026
1 of 2 checks passed
@Prajna1999
Prajna1999 deleted the feat/auth-authz-with-backend branch September 11, 2026 11:17
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.

Guardrails: Enhance authentication security

2 participants