SCIM 2.0 Support
Overview
SCIM is an open standard that allows for the automation of user provisioning. When enabled, your identity provider can automatically:
- Create users in Hrida.ai when they're added to your organization
- Update user information when changes are made
- Deactivate users when they're removed from your organization
- Manage group memberships
Configuration
SCIM is configured entirely through environment variables. There is no UI configuration for SCIM settings.
Environment Variables
Configure SCIM by setting these environment variables:
SCIM_ENABLED: Set totrueto enable SCIM support (default:false)SCIM_TOKEN: The bearer token for SCIM authentication (required when SCIM is enabled)SCIM_AUTH_PROVIDER: The OAuth provider name to associate with SCIMexternalIdvalues (e.g.,microsoft,oidc). Required forexternalIdstorage and account linking.
Security Note The SCIM token should be a secure, randomly generated string. You can generate one using:
openssl rand -base64 32Keep this token secure as it provides access to user management operations.
Example Configuration
# Enable SCIM
export SCIM_ENABLED=true
# Set a secure token (replace with your own generated token)
export SCIM_TOKEN="your-secure-token-here"
# Set the OAuth provider name for externalId linking
export SCIM_AUTH_PROVIDER="microsoft"SCIM API Configuration
When configuring your identity provider, use the following settings:
- SCIM Base URL:
<your-hridaai-url>/api/v1/scim/v2/ - Authentication: Bearer Token
- Token:
Bearer <your-scim-token>
Example for Popular Identity Providers
Okta
- In Okta, add the SCIM application
- Set the SCIM connector base URL to:
https://your-domain.com/api/v1/scim/v2/ - Set authentication to "HTTP Header"
- Add Authorization header with value:
Bearer your-scim-token
Supported SCIM Operations
Hrida.ai's SCIM implementation supports the following operations:
User Operations
- Create User (
POST /Users): Create a new user account - Get User (
GET /Users/{id}): Retrieve user information - Update User (
PUT /Users/{id},PATCH /Users/{id}): Update user attributes - Delete User (
DELETE /Users/{id}): Deactivate a user account - List Users (
GET /Users): List all users with filtering support
Group Operations
- Create Group (
POST /Groups): Create a new group - Get Group (
GET /Groups/{id}): Retrieve group information - Update Group (
PUT /Groups/{id},PATCH /Groups/{id}): Update group membership - Delete Group (
DELETE /Groups/{id}): Remove a group - List Groups (
GET /Groups): List all groups with filtering support
Supported Attributes
User Attributes
userName: The user's email address (required, unique)name.givenName: First namename.familyName: Last nameemails: Email addresses (when multiple are provided, the entry markedprimary: trueis used)active: User status (active/inactive)externalId: External identifier from the identity provider (stored per-provider in the user'sscimJSON field, see externalId and Account Linking)
Group Attributes
displayName: Group name (required)members: Array of user membersexternalId: External identifier from the identity provider
Filtering Support
The SCIM API supports filtering for both users and groups:
GET /api/v1/scim/v2/Users?filter=userName eq "user@example.com"
GET /api/v1/scim/v2/Users?filter=externalId eq "abc-123"
GET /api/v1/scim/v2/Groups?filter=displayName eq "Engineering"
Supported filter operators:
eq: Equalsne: Not equalsco: Containssw: Starts withew: Ends withpr: Present (has value)gt: Greater thange: Greater than or equallt: Less thanle: Less than or equal
externalId and Account Linking
When SCIM_AUTH_PROVIDER is configured, Hrida.ai stores externalId values in a per-provider structure within the user's scim JSON field:
{
"microsoft": { "external_id": "abc-123" },
"okta": { "external_id": "def-456" }
}This enables several behaviors:
- User lookup by externalId: When an identity provider sends a
filter=externalId eq "..."request, Hrida.ai searches thescimfield for a matching entry under the configured provider. - OAuth fallback: If no user is found by
externalId, Hrida.ai falls back to matching against OAuthsubvalues, automatically linking SCIM-provisioned accounts with existing OAuth-authenticated users. - Create and update: When creating or updating users via SCIM, the
externalIdis stored in thescimfield and returned in subsequent responses.
If SCIM_AUTH_PROVIDER is not set while SCIM is enabled, any operation that requires externalId (creation, lookup, or update) will return a 500 error. A warning is also logged on startup to alert you.
Troubleshooting
Common Issues
-
401 Unauthorized Errors
- Verify that
SCIM_ENABLEDis set totrue - Check that the bearer token in your identity provider matches
SCIM_TOKEN - Ensure the Authorization header format is:
Bearer <token>
- Verify that
-
404 Not Found Errors
- Verify the SCIM base URL ends with
/api/v1/scim/v2/ - Check that the path includes the
/api/v1prefix
- Verify the SCIM base URL ends with
-
User Creation Failures
- Ensure the
userNamefield contains a valid email address - Check that the email or
externalIdis not already in use
- Ensure the
-
500 Error on externalId Operations
- Verify that
SCIM_AUTH_PROVIDERis set to the correct OAuth provider name
- Verify that
Testing SCIM Endpoints
You can test SCIM endpoints using curl:
# Test authentication and list users
curl -H "Authorization: Bearer your-scim-token" \
https://your-domain.com/api/v1/scim/v2/Users
# Get a specific user
curl -H "Authorization: Bearer your-scim-token" \
https://your-domain.com/api/v1/scim/v2/Users/user-id
# Create a test user
curl -X POST \
-H "Authorization: Bearer your-scim-token" \
-H "Content-Type: application/scim+json" \
-d '{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "test@example.com",
"externalId": "idp-user-id-123",
"displayName": "Test User",
"name": {
"givenName": "Test",
"familyName": "User"
},
"emails": [{
"value": "test@example.com",
"primary": true
}],
"active": true
}' \
https://your-domain.com/api/v1/scim/v2/UsersSecurity Considerations
- Use HTTPS: Always use HTTPS in production to protect the bearer token
- Secure Token Storage: Store the SCIM token securely and rotate it periodically
- IP Allowlisting: Consider restricting SCIM API access to your identity provider's IP addresses
- Audit Logging: SCIM operations are logged for security auditing
Limitations
- Custom schema extensions are not currently supported
- Bulk operations are not implemented
- ETags for resource versioning are not supported
Integration with SSO
SCIM works best when combined with SSO (Single Sign-On). A typical setup includes:
- SCIM for automated user provisioning
- OIDC for user authentication
This ensures users are automatically created and can immediately authenticate using their corporate credentials.
For SSO configuration, see the SSO documentation.