ScimServer

Struct ScimServer 

Source
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

§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>

Source

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.

Source

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.

Source

pub fn discover_capabilities_with_introspection( &self, ) -> Result<ProviderCapabilities, ScimError>

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.

Source

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.

Source

pub fn get_service_provider_config_with_introspection( &self, ) -> Result<ServiceProviderConfig, ScimError>

Generate ServiceProviderConfig with provider introspection

This version works with providers that implement CapabilityIntrospectable for more detailed capability information.

Source

pub fn supports_operation( &self, resource_type: &str, operation: &ScimOperation, ) -> bool

Check if a specific operation is supported for a resource type

Source

pub fn provider(&self) -> &P

Get a reference to the underlying provider.

This allows access to provider-specific functionality like conditional operations.

Source§

impl<P: ResourceProvider + Sync> ScimServer<P>

Source

pub async fn create_resource( &self, resource_type: &str, data: Value, context: &RequestContext, ) -> ScimResult<Resource>

Generic create operation for any resource type

Source

pub async fn get_resource( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<Option<Resource>>

Generic read operation

Source

pub async fn update_resource( &self, resource_type: &str, id: &str, data: Value, context: &RequestContext, ) -> ScimResult<Resource>

Generic update operation

Source

pub async fn delete_resource( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<()>

Generic delete operation

Source

pub async fn list_resources( &self, resource_type: &str, context: &RequestContext, ) -> ScimResult<Vec<Resource>>

Generic list operation for any resource type

Source

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)

Source

pub async fn resource_exists( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> ScimResult<bool>

Check if a resource exists

Source

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>

Source

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

Source

pub fn get_supported_resource_types(&self) -> Vec<&str>

Get all registered resource types

Source

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>

Source

pub fn get_resource_schema(&self, resource_type: &str) -> ScimResult<Schema>

Get schema for any registered resource type

Source

pub fn get_all_schemas(&self) -> Vec<&Schema>

Get all registered schemas

Source

pub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>

Get schema from schema registry by ID

Auto Trait Implementations§

§

impl<P> Freeze for ScimServer<P>
where P: Freeze,

§

impl<P> !RefUnwindSafe for ScimServer<P>

§

impl<P> Send for ScimServer<P>
where P: Send,

§

impl<P> Sync for ScimServer<P>
where P: Sync,

§

impl<P> Unpin for ScimServer<P>
where P: Unpin,

§

impl<P> !UnwindSafe for ScimServer<P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TenantValidator for T

Source§

fn validate_tenant_context( &self, expected_tenant_id: &str, context: &RequestContext, ) -> Result<(), String>

Validate that the context has the expected tenant.
Source§

fn validate_single_tenant_context( &self, context: &RequestContext, ) -> Result<(), String>

Validate that the context is for single-tenant operation.
Source§

fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>

Extract tenant context or return error for multi-tenant operations.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.