ExScim.Config (ex_scim v0.2.2)

Copy Markdown View Source

Centralized configuration management for ExScim.

Summary

Functions

Returns the list of authentication schemes supported by the SCIM service provider.

Returns the configured base URL for SCIM endpoints.

Returns the maximum number of operations per bulk request.

Returns the maximum payload size in bytes for bulk operations.

Returns whether SCIM bulk operations are supported.

Returns whether SCIM change password operations are supported.

Generates a SCIM resource collection URL for the given resource type.

Generates a SCIM collection URL, using a tenant-specific base URL when available.

Returns the documentation URI for the SCIM service provider, or nil if not configured.

Returns whether SCIM ETag support is enabled.

Returns the maximum number of results for filter queries.

Returns whether SCIM filter operations are supported.

Returns whether SCIM PATCH operations are supported.

Returns the configured resource types supported by this SCIM service provider.

Generates a full SCIM resource URL for the given resource type and ID.

Generates a full SCIM resource URL, using a tenant-specific base URL when available.

Returns the list of schema modules to use for SCIM schema definitions.

Returns the configured base URL with the SCIM v2 API path appended.

Returns whether SCIM sort operations are supported.

Functions

authentication_schemes()

@spec authentication_schemes() :: [map()]

Returns the list of authentication schemes supported by the SCIM service provider.

Each scheme is a map with string keys matching RFC 7643 (type, name, description, and optionally specUri, documentationUri, primary).

base_url()

@spec base_url() :: String.t()

Returns the configured base URL for SCIM endpoints.

The base URL is used for generating location headers, documentation URIs, and other absolute URLs in SCIM responses.

Configuration sources (in order of precedence):

  1. Application environment: :ex_scim, :base_url
  2. System environment variable: SCIM_BASE_URL
  3. Default fallback: "http://localhost:4000"

Examples

iex> ExScim.Config.base_url()
"http://localhost:4000"

When config :ex_scim, base_url: "https://api.example.com" is set, that value is returned instead.

bulk_max_operations()

@spec bulk_max_operations() :: integer()

Returns the maximum number of operations per bulk request.

bulk_max_payload_size()

@spec bulk_max_payload_size() :: integer()

Returns the maximum payload size in bytes for bulk operations.

bulk_supported()

@spec bulk_supported() :: boolean()

Returns whether SCIM bulk operations are supported.

change_password_supported()

@spec change_password_supported() :: boolean()

Returns whether SCIM change password operations are supported.

collection_url(resource_type)

@spec collection_url(String.t()) :: String.t()

Generates a SCIM resource collection URL for the given resource type.

Examples

iex> ExScim.Config.collection_url("Users")
"http://localhost:4000/scim/v2/Users"

collection_url(resource_type, scope)

@spec collection_url(String.t(), ExScim.Scope.t() | nil) :: String.t()

Generates a SCIM collection URL, using a tenant-specific base URL when available.

documentation_uri()

@spec documentation_uri() :: String.t() | nil

Returns the documentation URI for the SCIM service provider, or nil if not configured.

etag_supported()

@spec etag_supported() :: boolean()

Returns whether SCIM ETag support is enabled.

filter_max_results()

@spec filter_max_results() :: integer()

Returns the maximum number of results for filter queries.

filter_supported()

@spec filter_supported() :: boolean()

Returns whether SCIM filter operations are supported.

patch_supported()

@spec patch_supported() :: boolean()

Returns whether SCIM PATCH operations are supported.

resource_types()

@spec resource_types() :: [map()]

Returns the configured resource types supported by this SCIM service provider.

Each resource type is a map with the following keys:

  • :id - unique identifier (e.g., "User")
  • :name - display name
  • :endpoint - the URL path suffix (e.g., "/Users")
  • :description - human-readable description
  • :schema - the core schema URI for this resource type
  • :schema_extensions - list of extension maps, each with :schema (URI) and :required (boolean)

Configuration

config :ex_scim, :resource_types, [
  %{
    id: "User",
    name: "User",
    endpoint: "/Users",
    description: "User Account",
    schema: "urn:ietf:params:scim:schemas:core:2.0:User",
    schema_extensions: [
      %{schema: "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User", required: false}
    ]
  }
]

Default

When not configured, defaults to User (with Enterprise extension) and Group.

resource_url(resource_type, resource_id)

@spec resource_url(String.t(), String.t()) :: String.t()

Generates a full SCIM resource URL for the given resource type and ID.

Examples

iex> ExScim.Config.resource_url("Users", "123")
"http://localhost:4000/scim/v2/Users/123"

iex> ExScim.Config.resource_url("Groups", "456")
"http://localhost:4000/scim/v2/Groups/456"

resource_url(resource_type, resource_id, scope)

@spec resource_url(String.t(), String.t(), ExScim.Scope.t() | nil) :: String.t()

Generates a full SCIM resource URL, using a tenant-specific base URL when available.

When a scope with a tenant_id is provided and the configured tenant resolver implements the optional tenant_scim_base_url/1 callback, that URL is used as the base. Otherwise, falls back to the global scim_base_url/0.

Examples

iex> ExScim.Config.resource_url("Users", "123", nil)
"http://localhost:4000/scim/v2/Users/123"

schema_modules()

@spec schema_modules() :: [module()]

Returns the list of schema modules to use for SCIM schema definitions.

Each module must implement the Schema Builder DSL and provide schema_id/0 and to_map/0 functions.

Configuration

config :ex_scim, :schema_modules, [
  MyApp.Schemas.User,
  MyApp.Schemas.Group
]

Default

When not configured, defaults to the built-in schema definitions:

scim_base_url()

@spec scim_base_url() :: String.t()

Returns the configured base URL with the SCIM v2 API path appended.

This is a convenience function for generating SCIM v2 endpoint URLs.

Examples

iex> ExScim.Config.scim_base_url()
"http://localhost:4000/scim/v2"

sort_supported()

@spec sort_supported() :: boolean()

Returns whether SCIM sort operations are supported.