Expand description
Multi-tenant SCIM server capabilities.
This module provides the core infrastructure for multi-tenant SCIM operations, including tenant resolution, multi-tenant resource providers, and tenant-aware error handling.
§Architecture
The multi-tenant system is built around several key concepts:
- Tenant Resolution: Mapping authentication credentials to tenant contexts
- Multi-Tenant Providers: Resource providers that understand tenant isolation
- Enhanced Context: Request contexts that carry tenant information
- Isolation Levels: Different levels of tenant data separation
§Example Usage
use scim_server::multi_tenant::{
TenantValidator, TenantResolver, StaticTenantResolver
};
use scim_server::{TenantContext, RequestContext, Resource, ResourceProvider};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set up tenant resolver
let resolver = StaticTenantResolver::new();
resolver.add_tenant("api-key-123", TenantContext::new(
"tenant-a".to_string(),
"client-a".to_string()
)).await;
// Use in multi-tenant operations
let tenant_context = resolver.resolve_tenant("api-key-123").await?;
let context = RequestContext::with_tenant_generated_id(tenant_context);
let user_data = json!({
"userName": "john.doe",
"displayName": "John Doe"
});
Ok(())
}Re-exports§
pub use adapter::SingleTenantAdapter;pub use adapter::ToSingleTenant;pub use scim_config::RateLimit;pub use scim_config::ScimAuditConfig;pub use scim_config::ScimAuthScheme;pub use scim_config::ScimClientAuth;pub use scim_config::ScimClientConfig;pub use scim_config::ScimConfigurationError;pub use scim_config::ScimCustomAttribute;pub use scim_config::ScimEndpointConfig;pub use scim_config::ScimOperation;pub use scim_config::ScimRateLimits;pub use scim_config::ScimSchemaConfig;pub use scim_config::ScimSchemaExtension;pub use scim_config::ScimSearchConfig;pub use scim_config::ScimTenantConfiguration;pub use provider::TenantValidator;pub use resolver::StaticTenantResolver;pub use resolver::StaticTenantResolverBuilder;pub use resolver::TenantResolver;pub use crate::resource::IsolationLevel;pub use crate::resource::TenantContext;pub use crate::resource::TenantPermissions;
Modules§
- adapter
- Provider adapter utilities for the unified ResourceProvider trait.
- provider
- Multi-tenant provider utilities and validation helpers.
- resolver
- Tenant resolution for multi-tenant SCIM operations.
- scim_
config - SCIM-specific tenant configuration for multi-tenant SCIM operations.