SCIM Gateway
repository·master·Indexed 42 days ago
https://github.com/jelhub/scimgatewayAn identity integration gateway that translates SCIM 1.1 and 2.0 requests into endpoint-specific protocols including REST, SQL, NoSQL, LDAP, and SOAP. Version 6.2.10 provides pre-built plugins for Microsoft Entra ID, MongoDB, MS SQL Server, SAP HANA, and Active Directory, enabling seamless identity provisioning to diverse target systems.
What's inside SCIM Gateway
- SCIM Gateway is an identity integration gateway that translates SCIM 1.1 and SCIM 2.0 requests into endpoint-specific protocols. It allows you to turn any destination (such as REST, SQL, NoSQL, LDAP, or SOAP) into a SCIM-compatible interface, preventing vendor lock-in by acting as a translation layer between identity providers and target systems.
Understand the local `saml` package in SCIM Gateway
masterThe
lib/samldirectory contains a modified local copy of thenode-samlpackage (v4.0.0). This local version is used instead of the standard npm package to ensure compatibility when SCIM Gateway plugins are compiled into standalone binaries usingbun build --compile.In the original
node-samlpackage, XML templates were loaded from the file system usingfs.readFileSyncand__dirname. When compiled into a binary, these absolute paths from the build machine would fail on other machines (resulting inENOENTerrors). The local version solves this by inlining the XML templates as string constants directly within the code, removing the runtime dependency on external.templatefiles.Implement Gateway Chaining
masterChain multiple gateways (
gateway1 → gateway2 → gateway3 → endpoint). Each gateway validates authorization and forwards the request unlesspassThroughis enabled.Gateway 1 configuration:
{ "scimgateway": { "chainingBaseUrl": "https://gateway2:8880", "auth": { "passThrough": { "enabled": false } } } }In chaining mode, the plugin binary is only used for initialization. A simplified plugin implementation is sufficient:
import { ScimGateway } from 'scimgateway' const scimgateway = new ScimGateway() const config = scimgateway.getConfig() scimgateway.authPassThroughAllowed = true scimgateway.pluginAndOrFilterEnabled = falseConfigure SCIM Gateway as a Windows Task for auto-start
masterTo ensure SCIM Gateway starts automatically on Windows, create a task in Task Scheduler (
taskschd.msc) with these settings:Tab Setting Value General Name SCIM GatewayGeneral User SYSTEMGeneral Privileges Run with highest privileges Triggers Begin the task At startup Actions Start a program <bun-install-path>\bun.exeActions Arguments c:\my-scimgatewaySettings Stop the task if it runs longer than Disabled Verification:
- Confirm the process appears in Task Manager after running the task.
- Confirm the process disappears after clicking 'End'.
- Confirm auto-start after a system reboot.
Build a custom SCIM plugin
masterTo create a custom plugin for SCIM Gateway, follow these steps:
- Scaffold: Copy an existing example plugin (e.g.,
lib/plugin-mssql.tsandconfig/plugin-mssql.json) and rename them with your own prefix (e.g.,plugin-mine). - Configure: Set a unique
portin your new configuration file (e.g.,config/plugin-mine.json). - Register: Import your plugin in
index.tsusingimport './lib/plugin-mine.ts'. - Initialize: Ensure you perform the mandatory plugin initialization in your entry point.
- Verify: Start the gateway to confirm the plugin is loaded.
Recommended Editor: Visual Studio Code is recommended as it provides IntelliSense for all
scimgatewaymethods.// Example registration in index.ts import './lib/plugin-mine.ts';- Scaffold: Copy an existing example plugin (e.g.,
Integrate Microsoft Entra ID as an Identity Provider
masterMicrosoft Entra ID can provision users to SCIM Gateway, which then forwards them to your endpoint plugin.
Plugin Configuration
Your plugin must support the following configuration structure for authentication:
"scimgateway": { "scim": { "version": "2.0" }, "auth": { "bearerToken": [ { "token": "shared-secret" } ], "bearerJwt": [ { "azureTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } ] } }tokenmust match the "Secret Token" in Entra ID provisioning.azureTenantIdmust match the Entra tenant ID.- If "Secret Token" is blank in Entra ID,
bearerJwtis used automatically.
Required Attribute Mappings
Object Source Target Matching User userPrincipalNameuserNamePrecedence #1 Group displayNamedisplayNamePrecedence #1 Group membersmembers— Entra ID Behavior
- Deletions: Entra ID sends
PATCH { "active": "False" }instead of aDELETErequest. - Keep-alive: Entra ID periodically checks for non-existent users/groups.
- Existence Check: Entra ID checks for existence before creating users.
"scimgateway": { "scim": { "version": "2.0" }, "auth": { "bearerToken": [{ "token": "shared-secret" }], "bearerJwt": [{ "azureTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }] } }Run SCIM Gateway manually
masterYou can start the SCIM Gateway using
bun. Depending on your directory structure, use one of the following commands:# If in the package root bun . # Using the absolute path to the directory bun c:\my-scimgateway # Using the path to the entrypoint bun c:\my-scimgateway\index.tsPress
Ctrl+Cto stop the process.bun .Deploy SCIM Gateway using Docker
masterSingle Image Build
To build and run a single container, follow these steps:
mkdir /opt/my-scimgateway cd /opt/my-scimgateway bun init -y bun install scimgateway bun pm trust scimgateway cp ./config/docker/* . cp ./config/docker/.dockerignore . # Build the image docker build --platform linux/amd64 --force-rm=true -t my-scimgateway:1.0.0 . # Create and run the container docker create --init --ulimit memlock=-1:-1 --name my-scimgateway -p 8880:8880 my-scimgateway:1.0.0 docker start my-scimgatewayNote: If using encrypted configuration files, pass
-e SEED=<random>during thedocker createstep.Docker Compose Setup
For a persistent setup using Docker Compose:
mkdir /opt/my-scimgateway && cd /opt/my-scimgateway bun init -y && bun install scimgateway && bun pm trust scimgateway cp ./config/docker/* . # Setup user and config directory adduser scimgateway mkdir /home/scimgateway/config # Copy plugin configuration to the persistent volume scp config/plugin-loki.json scimgateway@host:/home/scimgateway/config/ # Start the stack docker-compose up --build -dProvided Compose Files
docker-compose.yml: Main file for setting exposed ports and environment variables.Dockerfile: Main image definition.DataDockerfile: Used for volume mapping.docker-compose-debug.yml: Used to attach a VS Code debugger.docker-compose-mssql.yml: Example including an MSSQL container.
docker build --platform linux/amd64 --force-rm=true -t my-scimgateway:1.0.0 .Configure the Entra ID Provisioning Plugin
masterThe
plugin-entra-idprovisions users and groups to Microsoft Entra ID via the Microsoft Graph API.1. App Registration Requirements
Register an app in Microsoft Entra ID → App registrations and grant the following Application permissions (Microsoft Graph):
Directory.ReadWriteAll(Required)Organization.ReadWrite.All(Required)AuditLog.Read.All(Optional: formap.user.signInActivity; requires Entra ID Premium)UserAuthenticationMethod.ReadWrite.All(Optional: formap.user.mfa)RoleEligibilitySchedule.ReadWrite.Directory(Optional: for PIM roles)RoleManagement.ReadWrite.Directory(Optional: for PIM roles)EntitlementManagement.ReadWrite.All(Optional: for Access Packages)
Note: After adding permissions, you must click Grant admin consent.
2. Plugin Configuration
In your
index.ts, import the plugin:import './lib/plugin-entra-id.ts' export {}Configure
config/plugin-entra-id.jsonwith your credentials.clientSecretand proxy passwords are automatically encrypted on the first connection:{ "scimgateway": { "scim": { "version": "2.0", "skipTypeConvert": true }, "auth": { "basic": [ { "username": "gwadmin", "password": "password", "readOnly": false } ] } }, "endpoint": { "entity": { "undefined": { "connection": { "baseUrls": [], "auth": { "type": "oauth", "options": { "azureTenantId": "<Tenant ID>", "clientId": "<Application ID>", "clientSecret": "<Secret value>" } } } } } } }Install SCIM Gateway using Bun
masterTo install SCIM Gateway, you must first have Bun installed. The installation process initializes a new project and copies example files (including
index.ts,lib/, andconfig/) into your directory.Note: Running
bun pm trust scimgatewayis required to allow thepostinstallscript to copy these example files into your package directory.mkdir c:\my-scimgateway cd c:\my-scimgateway bun init -y bun install scimgateway bun pm trust scimgatewayConfigure SCIM Gateway plugins
masterPlugins are defined by an entry point in
index.tsand a corresponding configuration file. Each plugin requires a TypeScript file and a JSON configuration file that share the same name prefix.Example structure:
lib/plugin-entra-id.tsconfig/plugin-entra-id.json
The JSON configuration file must contain two top-level objects:
scimgateway: Contains gateway core settings (port, auth, logging, TLS).endpoint: Contains plugin-specific connection details (host, credentials, mappings).
To start one or more plugins, import them in your
index.tsentry point.// Start one or more plugins: import './lib/plugin-entra-id.ts' export {}Upgrade SCIM Gateway
masterThe recommended upgrade path is to rename your existing package folder, perform a fresh installation, and then manually copy your customized
index.ts,config/, andlib/files from the old installation to the new one.Minor upgrade:
bun install scimgatewayMajor upgrade:
bun install scimgateway@latestNote: Major upgrades may break existing plugins. Review the changelog before proceeding.
Production Note: To exclude example plugins in production environments using npm or Node.js, set the environment variable
SCIMGATEWAY_POSTINSTALL_SKIP=trueor addscimgateway_postinstall_skip = trueto your.npmrcfile.# Minor upgrade bun install scimgateway # Major upgrade bun install scimgateway@latest