scim_server/
lib.rs

1//! SCIM 2.0 server library for Rust.
2//!
3//! A modern, type-safe implementation of the SCIM 2.0 protocol with clean architecture,
4//! multi-tenant support, and pluggable storage backends.
5//!
6//! # Core Architecture
7//!
8//! This library follows a clean, layered architecture:
9//!
10//! - **SCIM Protocol Layer**: [`ScimServer`] handles SCIM HTTP operations
11//! - **Resource Layer**: [`Resource`] provides type-safe resource representation
12//! - **Storage Layer**: [`ResourceProvider`] trait for pluggable backends
13//! - **Schema Layer**: [`Schema`] definitions with validation
14//! - **Multi-tenancy**: Built-in support via [`TenantContext`]
15//!
16//! # Quick Start
17//!
18//! ```rust,no_run
19//! use scim_server::ScimServer;
20//! use scim_server::providers::StandardResourceProvider;
21//! use scim_server::storage::InMemoryStorage;
22//! use std::sync::Arc;
23//!
24//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
25//! // 1. Set up storage and provider
26//! let storage = InMemoryStorage::new();
27//! let provider = StandardResourceProvider::new(storage);
28//!
29//! // 2. Create SCIM server
30//! let server = ScimServer::new(provider)?;
31//!
32//! // 3. Server is ready for HTTP integration
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! # Key Features
38//!
39//! - **Type Safety**: Value objects with compile-time validation
40//! - **Multi-tenant**: Full tenant isolation with configurable strategies
41//! - **Async First**: Built on async/await for high performance
42//! - **Pluggable Storage**: Bring your own database via [`ResourceProvider`]
43//! - **Schema Validation**: Automatic validation against SCIM schemas
44//! - **Version Control**: ETag-based optimistic concurrency control
45//! - **Extensible**: Support for custom schemas and value objects
46//!
47//! # Architecture Overview
48//!
49//! ```text
50//! ┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
51//! │   HTTP Layer    │───▶│   ScimServer     │───▶│ Operation       │
52//! │   (Axum/etc)    │    │   (Protocol)     │    │ Handler         │
53//! └─────────────────┘    └──────────────────┘    └─────────────────┘
54//!                                 │                        │
55//!                                 ▼                        ▼
56//! ┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
57//! │     Schema      │    │    Resource      │    │ ResourceProvider│
58//! │   Validation    │    │  (Value Objects) │    │   (Storage)     │
59//! └─────────────────┘    └──────────────────┘    └─────────────────┘
60//! ```
61
62pub mod auth;
63pub mod error;
64/// Model Context Protocol integration for AI agents.
65///
66/// This module is only available when the `mcp` feature is enabled.
67/// Add `features = ["mcp"]` to your Cargo.toml dependency to use this module.
68#[cfg(feature = "mcp")]
69pub mod mcp_integration;
70pub mod multi_tenant;
71pub mod operation_handler;
72pub mod provider_capabilities;
73pub mod providers;
74pub mod resource;
75pub mod resource_handlers;
76pub mod schema;
77pub mod schema_discovery;
78pub mod scim_server;
79pub mod storage;
80
81// Re-export commonly used types for convenience
82pub use error::{ScimError, ScimResult};
83pub use providers::ResourceProvider;
84pub use resource::{IsolationLevel, TenantPermissions};
85pub use resource::{ListQuery, RequestContext, Resource, ScimOperation, TenantContext};
86pub use schema::{Schema, SchemaRegistry};
87pub use schema_discovery::SchemaDiscovery;
88pub use scim_server::{ScimServer, ScimServerBuilder, ScimServerConfig, TenantStrategy};
89
90// Re-export additional types needed by examples and advanced usage
91pub use operation_handler::{
92    OperationMetadata, ScimOperationHandler, ScimOperationRequest, ScimOperationResponse,
93};
94pub use provider_capabilities::{
95    AuthenticationCapabilities, BulkCapabilities, CapabilityIntrospectable, ExtendedCapabilities,
96    FilterOperator, PaginationCapabilities, ProviderCapabilities,
97};
98pub use resource_handlers::{create_group_resource_handler, create_user_resource_handler};
99pub use schema_discovery::AuthenticationScheme;
100
101// Multi-tenant types
102pub use multi_tenant::{ScimTenantConfiguration, StaticTenantResolver, TenantResolver};
103
104// MCP integration re-exports (feature-gated)
105/// Model Context Protocol integration types.
106///
107/// These types are only available when the `mcp` feature is enabled.
108/// Add `features = ["mcp"]` to your Cargo.toml dependency to use these types.
109#[cfg(feature = "mcp")]
110pub use mcp_integration::{McpServerInfo, ScimMcpServer, ScimToolResult};