File size: 2,990 Bytes
469eae6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# SCIM v2 Integration for LiteLLM Proxy

This module provides SCIM v2 (System for Cross-domain Identity Management) endpoints for LiteLLM Proxy, allowing identity providers to manage users and teams (groups) within the LiteLLM ecosystem.

## Overview

SCIM is an open standard designed to simplify user management across different systems. This implementation allows compatible identity providers (like Okta, Azure AD, OneLogin, etc.) to automatically provision and deprovision users and groups in LiteLLM Proxy.

## Endpoints

The SCIM v2 API follows the standard specification with the following base URL:

```
/scim/v2
```

### User Management

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/Users` | GET | List all users with pagination support |
| `/Users/{user_id}` | GET | Get a specific user by ID |
| `/Users` | POST | Create a new user |
| `/Users/{user_id}` | PUT | Update an existing user |
| `/Users/{user_id}` | DELETE | Delete a user |

### Group Management

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/Groups` | GET | List all groups with pagination support |
| `/Groups/{group_id}` | GET | Get a specific group by ID |
| `/Groups` | POST | Create a new group |
| `/Groups/{group_id}` | PUT | Update an existing group |
| `/Groups/{group_id}` | DELETE | Delete a group |

## SCIM Schema

This implementation follows the standard SCIM v2 schema with the following mappings:

### Users

- SCIM User ID β†’ LiteLLM `user_id`
- SCIM User Email β†’ LiteLLM `user_email`
- SCIM User Group Memberships β†’ LiteLLM User-Team relationships

### Groups

- SCIM Group ID β†’ LiteLLM `team_id`
- SCIM Group Display Name β†’ LiteLLM `team_alias`
- SCIM Group Members β†’ LiteLLM Team members list

## Configuration

To enable SCIM in your identity provider, use the full URL to the SCIM endpoint:

```
https://your-litellm-proxy-url/scim/v2
```

Most identity providers will require authentication. You should use a valid LiteLLM API key with administrative privileges.

## Features

- Full CRUD operations for users and groups
- Pagination support 
- Basic filtering support
- Automatic synchronization of user-team relationships
- Proper status codes and error handling per SCIM specification


## Example Usage

### Listing Users

```
GET /scim/v2/Users?startIndex=1&count=10
```

### Creating a User

```json
POST /scim/v2/Users
{
  "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
  "userName": "[email protected]",
  "active": true,
  "emails": [
    {
      "value": "[email protected]",
      "primary": true
    }
  ]
}
```

### Adding a User to Groups

```json
PUT /scim/v2/Users/{user_id}
{
  "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
  "userName": "[email protected]",
  "active": true,
  "emails": [
    {
      "value": "[email protected]",
      "primary": true
    }
  ],
  "groups": [
    {
      "value": "team-123",
      "display": "Engineering Team"
    }
  ]
}
```