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

Implement MSC4098: SCIM provisioning #17144

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17144.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for MSC4098 (SCIM provisioning protocol).
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
- [Users](admin_api/user_admin_api.md)
- [Server Version](admin_api/version_api.md)
- [Federation](usage/administration/admin_api/federation.md)
- [SCIM provisioning](usage/administration/admin_api/scim_api.md)
- [Manhole](manhole.md)
- [Monitoring](metrics-howto.md)
- [Reporting Homeserver Usage Statistics](usage/administration/monitoring/reporting_homeserver_usage_statistics.md)
Expand Down
257 changes: 257 additions & 0 deletions docs/usage/administration/admin_api/scim_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
# SCIM API

Synapse implement a basic subset of the SCIM 2.0 provisioning protocol as defined in [RFC7643](https://datatracker.ietf.org/doc/html/rfc7643) and [RFC7644](https://datatracker.ietf.org/doc/html/rfc7643).
This allows Identity Provider software to update user attributes in a standard and centralized way.

The SCIM endpoint is `/_matrix/client/unstable/coop.yaal/scim`.

## Installation

SCIM support for Synapse requires python 3.9+. The `matrix-synapse` package should be installed with the `scim` extra.

## Examples

### Create user

#### Request

```
POST /_matrix/client/unstable/coop.yaal/scim/Users
```

```json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "bjensen",
"externalId": "bjensen@test",
"phoneNumbers": [{"value": "+1-12345678"}],
"emails": [{"value": "[email protected]"}],
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen display name",
"password": "correct horse battery staple"
}
```

#### Response

```json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"meta": {
"resourceType": "User",
"created": "2024-07-22T16:59:16.326188+00:00",
"lastModified": "2024-07-22T16:59:16.326188+00:00",
"location": "https://synapse.example/_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test",
},
"id": "@bjensen:test",
"externalId": "@bjensen:test",
"phoneNumbers": [{"value": "+1-12345678"}],
"userName": "bjensen",
"emails": [{"value": "[email protected]"}],
"active": true,
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen display name"
}
```

### Get user

#### Request

```
GET /_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test
```

#### Response

```json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"meta": {
"resourceType": "User",
"created": "2024-07-22T16:59:16.326188+00:00",
"lastModified": "2024-07-22T16:59:16.326188+00:00",
"location": "https://synapse.example/_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test",
},
"id": "@bjensen:test",
"externalId": "@bjensen:test",
"phoneNumbers": [{"value": "+1-12345678"}],
"userName": "bjensen",
"emails": [{"value": "[email protected]"}],
"active": true,
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen display name"
}
```

### Get users

#### Request

Note that requests can be paginated using the `startIndex` and the `count` query string parameters:

```
GET /_matrix/client/unstable/coop.yaal/scim/Users?startIndex=10&count=1
```

#### Response

```json
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
"totalResults": 123,
"Resources": [
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"meta": {
"resourceType": "User",
"created": "2024-07-22T16:59:16.326188+00:00",
"lastModified": "2024-07-22T16:59:16.326188+00:00",
"location": "https://synapse.example/_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test",
},
"id": "@bjensen:test",
"externalId": "@bjensen:test",
"phoneNumbers": [{"value": "+1-12345678"}],
"userName": "bjensen",
"emails": [{"value": "[email protected]"}],
"active": true,
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen display name"
}
]
}
```

### Replace user

#### Request

```
PUT /_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test
```

```json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "bjensen",
"externalId": "bjensen@test",
"phoneNumbers": [{"value": "+1-12345678"}],
"emails": [{"value": "[email protected]"}],
"active": true,
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen new display name",
"password": "correct horse battery staple"
}
```

#### Response

```json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"meta": {
"resourceType": "User",
"created": "2024-07-22T16:59:16.326188+00:00",
"lastModified": "2024-07-22T17:34:12.834684+00:00",
"location": "https://synapse.example/_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test",
},
"id": "@bjensen:test",
"externalId": "@bjensen:test",
"phoneNumbers": [{"value": "+1-12345678"}],
"userName": "bjensen",
"emails": [{"value": "[email protected]"}],
"active": true,
"photos": [
{
"type": "photo",
"primary": true,
"value": "https://mydomain.tld/photo.webp"
}
],
"displayName": "bjensen new display name"
}
```

### Delete user

#### Request

```
DELETE /_matrix/client/unstable/coop.yaal/scim/Users/@bjensen:test
```

## Implementation details

### Models

The only SCIM resource type implemented is `User`, with the following attributes:
- `userName`
- `password`
- `emails`
- `phoneNumbers`
- `displayName`
- `photos` (as a MXC URI)
- `active`

The other SCIM User attributes will be ignored. Other resource types such as `Group` are not implemented.

### Endpoints

The implemented endpoints are:

- `/Users` (GET, POST)
- `/Users/<user_id>` (GET, PUT, DELETE)
- `/ServiceProviderConfig` (GET)
- `/Schemas` (GET)
- `/Schemas/<schema_id>` (GET)
- `/ResourceTypes` (GET)
- `/ResourceTypes/<resource_type_id>`

The following endpoints are not implemented:

- `/Users` (PATCH)
- [`/Me`](https://datatracker.ietf.org/doc/html/rfc7644#section-3.11) (GET, POST, PUT, PATCH, DELETE)
- `/Groups` (GET, POST, PUT, PATCH)
- [`/Bulk`](https://datatracker.ietf.org/doc/html/rfc7644#section-3.7) (POST)
- [`/.search`](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.3) (POST)

### Features

The following features are implemented:
- [pagination](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.4)

The following features are not implemented:
- [filtering](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2)
- [sorting](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.3)
- [attributes selection](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.5)
- [ETags](https://datatracker.ietf.org/doc/html/rfc7644#section-3.14)
55 changes: 53 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading