SCIM2 models serialization and validation with pydantic
Actively maintained. Last release 4 days ago, commits in 17 of the last 26 weeks. A safe choice.
pip install scim2-modelsscim2-models
Pydantic models for the SCIM 2.0 schemas and protocol. It parses and produces SCIM payloads as native Python objects, and serves as a basis for SCIM servers and clients.
Features
- Models for the resources and messages of RFC 7643 and RFC 7644:
User,Group,EnterpriseUser,Schema,ResourceType,ServiceProviderConfig,ListResponse,SearchRequest,PatchOpandError - Pydantic 2 models, with validation, serialization and IDE completion
- Validation and serialization per HTTP operation, driven by the SCIM attribute characteristics
required,mutability,returnedanduniqueness - SCIM filters and paths: parsing, validation against a model, and evaluation on resources
- PATCH operations applied to a resource, with the SCIM path grammar
- Schema extensions, and conversion between SCIM schemas and Python models
- Cursor-based pagination of RFC 9865
- SCIM exceptions, convertible to
Errorresponses
Standards
scim2-models implements:
It does not implement the other SCIM RFCs (yet):
Example
from scim2_models import User
import datetime
payload = {
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"id": "2819c223-7f76-453a-919d-413861904646",
"userName": "bjensen@example.com",
"meta": {
"resourceType": "User",
"created": "2010-01-23T04:56:22Z",
"lastModified": "2011-05-13T04:42:34Z",
"version": 'W\\/"3694e05e9dff590"',
"location": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646",
},
}
user = User.model_validate(payload)
assert user.user_name == "bjensen@example.com"
assert user.meta.created == datetime.datetime(
2010, 1, 23, 4, 56, 22, tzinfo=datetime.timezone.utc
)