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

(fix) auth checks - Add regex matching for models on virtual keys / teams #6901

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ishaan-jaff
Copy link
Contributor

@ishaan-jaff ishaan-jaff commented Nov 25, 2024

Add regex matching for models on virtual keys / teams

E2E Scenario

The following flow was raising an error - Fixed with this PR

Key Generate

curl -X POST https://endpoint/key/generate \
  -H 'Authorization: Bearer sk-token' \
  -H 'Content-Type: application/json' \
  --data-raw '{"models": ["llmengine/*"]}'

Chat Completions Request with new key

curl -X POST https://endpoint/v1/chat/completions \
  -H "Authorization: Bearer generated-key" \
  -d '{
    "model": "llmengine/specific-model",
    "messages": [{"role": "user", "content": "Test prompt"}]
  }'

Error Raised

{
  "error": {
    "message": "Authentication Error, API Key not allowed to access model. This token can only access models=['llmengine/*']. Tried to access llmengine/llama-3-1-8b-instruct",
    "type": "auth_error",
    "param": "None",
    "code": "401"
  }
}

Key Changes

  • Implemented regex pattern-based model access (e.g., "custom-llm-engine/*")
  • Ensure keys/teams with regex patterns can access all models in that regex pattern

Relevant issues

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

[REQUIRED] Testing - Attach a screenshot of any new tests passing locall

If UI changes, send a screenshot/GIF of working UI fixes

Copy link

vercel bot commented Nov 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 11:51pm

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/auth/auth_checks.py 89.28% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@krrishdholakia
Copy link
Contributor

Hey @ishaan-jaff i believe your missing testing for /model/info and /models endpoints -

async def test_proxy_model_group_alias_checks(prisma_client, hidden):

Copy link
Contributor

@krrishdholakia krrishdholakia left a comment

Choose a reason for hiding this comment

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

missing testing for /models and /model/info endpoints

if (
len(filtered_models) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove this?

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

Successfully merging this pull request may close these issues.

2 participants