pub struct ScimServer<P> { /* private fields */ }Expand description
Dynamic SCIM server for handling SCIM protocol operations.
The server coordinates between storage providers and SCIM protocol requirements, handling schema validation, resource lifecycle, and multi-tenant isolation. Resource types are registered at runtime, allowing for flexible configurations.
§Type Parameters
P- The resource provider type that implementsResourceProvider
§Examples
use scim_server::{ScimServer, providers::StandardResourceProvider};
use scim_server::storage::InMemoryStorage;
use scim_server::resource::ScimOperation;
let storage = InMemoryStorage::new();
let provider = StandardResourceProvider::new(storage);
let mut server = ScimServer::new(provider)?;
// Register resource types dynamically
// server.register_resource_type("User", handler, vec![ScimOperation::Create])?;Implementations§
Source§impl<P: ResourceProvider> ScimServer<P>
impl<P: ResourceProvider> ScimServer<P>
Sourcepub fn new(provider: P) -> Result<Self, ScimError>
pub fn new(provider: P) -> Result<Self, ScimError>
Creates a new SCIM server with the given resource provider.
Initializes the server with a schema registry containing standard SCIM schemas.
Resource types must be registered separately using register_resource_type.
§Arguments
provider- The resource provider for storage operations
§Errors
Returns ScimError::Internal if the schema registry cannot be initialized.
Sourcepub fn discover_capabilities(&self) -> Result<ProviderCapabilities, ScimError>
pub fn discover_capabilities(&self) -> Result<ProviderCapabilities, ScimError>
Automatically discover provider capabilities from current server configuration
This method introspects the registered resource types, schemas, and provider implementation to determine what capabilities are currently supported.
Sourcepub fn discover_capabilities_with_introspection(
&self,
) -> Result<ProviderCapabilities, ScimError>where
P: CapabilityIntrospectable,
pub fn discover_capabilities_with_introspection(
&self,
) -> Result<ProviderCapabilities, ScimError>where
P: CapabilityIntrospectable,
Discover capabilities with provider introspection
This version works with providers that implement CapabilityIntrospectable to get provider-specific capability information like bulk limits and authentication schemes.
Sourcepub fn get_service_provider_config(
&self,
) -> Result<ServiceProviderConfig, ScimError>
pub fn get_service_provider_config( &self, ) -> Result<ServiceProviderConfig, ScimError>
Generate SCIM ServiceProviderConfig from discovered capabilities
This automatically creates an RFC 7644 compliant ServiceProviderConfig that accurately reflects the current server capabilities.
Sourcepub fn get_service_provider_config_with_introspection(
&self,
) -> Result<ServiceProviderConfig, ScimError>where
P: CapabilityIntrospectable,
pub fn get_service_provider_config_with_introspection(
&self,
) -> Result<ServiceProviderConfig, ScimError>where
P: CapabilityIntrospectable,
Generate ServiceProviderConfig with provider introspection
This version works with providers that implement CapabilityIntrospectable for more detailed capability information.
Sourcepub fn supports_operation(
&self,
resource_type: &str,
operation: &ScimOperation,
) -> bool
pub fn supports_operation( &self, resource_type: &str, operation: &ScimOperation, ) -> bool
Check if a specific operation is supported for a resource type
Source§impl<P: ResourceProvider + Sync> ScimServer<P>
impl<P: ResourceProvider + Sync> ScimServer<P>
Sourcepub async fn create_resource(
&self,
resource_type: &str,
data: Value,
context: &RequestContext,
) -> ScimResult<Resource>
pub async fn create_resource( &self, resource_type: &str, data: Value, context: &RequestContext, ) -> ScimResult<Resource>
Generic create operation for any resource type
Sourcepub async fn get_resource(
&self,
resource_type: &str,
id: &str,
context: &RequestContext,
) -> ScimResult<Option<Resource>>
pub async fn get_resource( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<Option<Resource>>
Generic read operation
Sourcepub async fn update_resource(
&self,
resource_type: &str,
id: &str,
data: Value,
context: &RequestContext,
) -> ScimResult<Resource>
pub async fn update_resource( &self, resource_type: &str, id: &str, data: Value, context: &RequestContext, ) -> ScimResult<Resource>
Generic update operation
Sourcepub async fn delete_resource(
&self,
resource_type: &str,
id: &str,
context: &RequestContext,
) -> ScimResult<()>
pub async fn delete_resource( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<()>
Generic delete operation
Sourcepub async fn list_resources(
&self,
resource_type: &str,
context: &RequestContext,
) -> ScimResult<Vec<Resource>>
pub async fn list_resources( &self, resource_type: &str, context: &RequestContext, ) -> ScimResult<Vec<Resource>>
Generic list operation for any resource type
Sourcepub async fn find_resource_by_attribute(
&self,
resource_type: &str,
attribute: &str,
value: &Value,
context: &RequestContext,
) -> ScimResult<Option<Resource>>
pub async fn find_resource_by_attribute( &self, resource_type: &str, attribute: &str, value: &Value, context: &RequestContext, ) -> ScimResult<Option<Resource>>
Generic search by attribute (replaces find_user_by_username)
Sourcepub async fn resource_exists(
&self,
resource_type: &str,
id: &str,
context: &RequestContext,
) -> ScimResult<bool>
pub async fn resource_exists( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<bool>
Check if a resource exists
Sourcepub async fn patch_resource(
&self,
resource_type: &str,
id: &str,
patch_request: &Value,
context: &RequestContext,
) -> ScimResult<Resource>
pub async fn patch_resource( &self, resource_type: &str, id: &str, patch_request: &Value, context: &RequestContext, ) -> ScimResult<Resource>
Generic patch operation for any resource type
Source§impl<P: ResourceProvider> ScimServer<P>
impl<P: ResourceProvider> ScimServer<P>
Sourcepub fn register_resource_type(
&mut self,
resource_type: &str,
handler: ResourceHandler,
operations: Vec<ScimOperation>,
) -> Result<(), ScimError>
pub fn register_resource_type( &mut self, resource_type: &str, handler: ResourceHandler, operations: Vec<ScimOperation>, ) -> Result<(), ScimError>
Register a resource type with its handler and supported operations
Sourcepub fn get_supported_resource_types(&self) -> Vec<&str>
pub fn get_supported_resource_types(&self) -> Vec<&str>
Get all registered resource types
Sourcepub fn get_supported_operations(
&self,
resource_type: &str,
) -> Option<&Vec<ScimOperation>>
pub fn get_supported_operations( &self, resource_type: &str, ) -> Option<&Vec<ScimOperation>>
Get supported operations for a resource type
Source§impl<P: ResourceProvider> ScimServer<P>
impl<P: ResourceProvider> ScimServer<P>
Sourcepub fn get_resource_schema(&self, resource_type: &str) -> ScimResult<Schema>
pub fn get_resource_schema(&self, resource_type: &str) -> ScimResult<Schema>
Get schema for any registered resource type
Sourcepub fn get_all_schemas(&self) -> Vec<&Schema>
pub fn get_all_schemas(&self) -> Vec<&Schema>
Get all registered schemas
Sourcepub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>
pub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>
Get schema from schema registry by ID