mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(health): keep an internal team name a wildcard grant admits as its own target
This commit is contained in:
parent
59f15043fe
commit
2f174c38ff
2 changed files with 10 additions and 3 deletions
|
|
@ -49,6 +49,7 @@ from litellm.proxy.auth.auth_checks import (
|
|||
can_user_call_model,
|
||||
get_user_object,
|
||||
key_model_aliases_for_auth_check,
|
||||
model_matches_any_wildcard_pattern_in_list,
|
||||
team_model_aliases_for_auth_check,
|
||||
)
|
||||
from litellm.proxy.auth.auth_exception_handler import (
|
||||
|
|
@ -1260,10 +1261,13 @@ class _AccessGroupGrants:
|
|||
|
||||
def requested_name(self, name: str, public_names: Mapping[str, str], admitted_names: frozenset[str]) -> str:
|
||||
public_name: Final = public_names.get(name)
|
||||
if public_name is None or public_name not in admitted_names or name in self.granted_names:
|
||||
if public_name is None or public_name not in admitted_names or self._grants(name):
|
||||
return name
|
||||
return public_name
|
||||
|
||||
def _grants(self, name: str) -> bool:
|
||||
return name in self.granted_names or model_matches_any_wildcard_pattern_in_list(name, tuple(self.granted_names))
|
||||
|
||||
def narrow(self, serving_ids: frozenset[str], served_names: frozenset[str]) -> frozenset[str]:
|
||||
in_granted_groups: Final = serving_ids & self.ids_in_granted_groups
|
||||
granted_directly: Final = not self.granted_names.isdisjoint(served_names)
|
||||
|
|
|
|||
|
|
@ -4965,8 +4965,11 @@ async def test_health_endpoint_probes_only_the_access_groups_team_deployments_se
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_health_endpoint_probes_a_team_deployment_whose_internal_name_the_key_holds() -> None:
|
||||
caller: Final = _team_key(["premium", "model_name_team-a_9d2f6e01"])
|
||||
@pytest.mark.parametrize("internal_name_grant", ["model_name_team-a_9d2f6e01", "model_name_team-a_*"])
|
||||
async def test_health_endpoint_probes_a_team_deployment_whose_internal_name_the_key_holds(
|
||||
internal_name_grant: str,
|
||||
) -> None:
|
||||
caller: Final = _team_key(["premium", internal_name_grant])
|
||||
|
||||
probed: Final = await _live_probed_model_ids(_team_split_model_list("gpt-5.4-mini", "openai/gpt-5.4-mini"), caller)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue