Skip to content

Conversation

boopesh07
Copy link
Contributor

Title

Add a config to forward user headers to litellm internal user

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

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

Changes

Copy link

vercel bot commented Sep 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Sep 10, 2025 11:04pm

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

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

reviewed

_map_to_internal_user = False
try:
_map_to_internal_user = (
isinstance(general_settings.get("user_header_target"), str)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we not do it this way. Instead have a field called user_header_mappings like this: https://docs.litellm.ai/docs/proxy/token_auth#role-mapping-spec

then u can say
X-Open-Header: internal_user
X-Open-Email: end_user

Copy link
Contributor

Choose a reason for hiding this comment

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

please also add validation that the value entered e.g internal_user, end_user is a valid role. We this defined in proxy/_types.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishaan-jaff, should I make a backward-compatible change by keeping the existing field user_header_name behavior, or should I remove it because the user_header_mappings field will contain it?

user_header_mappings:
- header_name: X-OpenWebUI-User-Email
litellm_user_role: internal_user
- header_name: X-OpenWebUI-User-Email
litellm_user_role: external_user

@ishaan-jaff
Copy link
Contributor

ishaan-jaff commented Sep 11, 2025 via email

@boopesh07
Copy link
Contributor Author

Upgraded PR is linked
#14485

@boopesh07 boopesh07 closed this Sep 12, 2025
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