[Bug Fix] SCIM - add GET /ServiceProviderConfig (#12664)

* add scimv2 config endpoint

* test_get_service_provider_config
This commit is contained in:
Ishaan Jaff 2025-07-16 15:43:25 -07:00 • committed by GitHub
parent 6a7aab7b84
commit 43e7d5288f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 59 additions and 0 deletions

View file

@ -245,6 +245,21 @@ async def set_scim_content_type(response: Response):
response.headers["Content-Type"] = "application/scim+json"
@scim_router.get(
"/ServiceProviderConfig",
response_model=SCIMServiceProviderConfig,
status_code=200,
dependencies=[Depends(user_api_key_auth), Depends(set_scim_content_type)],
)
async def get_service_provider_config(request: Request):
"""Return SCIM Service Provider Configuration."""
meta = {
"resourceType": "ServiceProviderConfig",
"location": str(request.url),
}
return SCIMServiceProviderConfig(meta=meta)
# User Endpoints
@scim_router.get(
"/Users",

View file

@ -90,3 +90,25 @@ class SCIMPatchOperation(BaseModel):
class SCIMPatchOp(BaseModel):
schemas: List[str] = ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
Operations: List[SCIMPatchOperation]
# SCIM Service Provider Configuration Models
class SCIMFeature(BaseModel):
supported: bool
maxOperations: Optional[int] = None
maxPayloadSize: Optional[int] = None
maxResults: Optional[int] = None
class SCIMServiceProviderConfig(BaseModel):
schemas: List[str] = [
"urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
]
patch: SCIMFeature = SCIMFeature(supported=True)
bulk: SCIMFeature = SCIMFeature(supported=False)
filter: SCIMFeature = SCIMFeature(supported=False)
changePassword: SCIMFeature = SCIMFeature(supported=False)
sort: SCIMFeature = SCIMFeature(supported=False)
etag: SCIMFeature = SCIMFeature(supported=False)
authenticationSchemes: Optional[List[Dict[str, Any]]] = None
meta: Optional[Dict[str, Any]] = None

View file

@ -8,12 +8,15 @@ from litellm.proxy.management_endpoints.scim.scim_v2 import (
UserProvisionerHelpers,
_handle_team_membership_changes,
create_user,
get_service_provider_config,
patch_user,
update_user,
)
from litellm.types.proxy.management_endpoints.scim_v2 import (
SCIMFeature,
SCIMPatchOp,
SCIMPatchOperation,
SCIMServiceProviderConfig,
SCIMUser,
SCIMUserEmail,
SCIMUserGroup,
@ -557,3 +560,22 @@ async def test_patch_user_not_found(mocker):
# Should raise ProxyException (which wraps the HTTPException)
with pytest.raises(ProxyException):
await patch_user(user_id="nonexistent-user", patch_ops=patch_ops)
@pytest.mark.asyncio
async def test_get_service_provider_config(mocker):
"""Test the get_service_provider_config endpoint"""
# Mock the Request object
mock_request = mocker.MagicMock()
mock_request.url = "https://example.com/scim/v2/ServiceProviderConfig"
# Call the endpoint
result = await get_service_provider_config(mock_request)
# Verify it returns the correct response
assert isinstance(result, SCIMServiceProviderConfig)
assert result.schemas == ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"]
assert result.patch.supported is True
assert result.bulk.supported is False
assert result.meta is not None
assert result.meta["resourceType"] == "ServiceProviderConfig"