โ—† Oryn
Docs โ€บ Admin โ€บ Admin: Users, Roles & SSO

๐Ÿ‘ค Admin: Users, Roles & SSO

Provision users, assign roles, manage organisations, and sync your directory โ€” all from one admin-gated surface.

Overview

The Users, Roles & SSO area gives workspace admins full control over who can access Oryn and what they can do. From here you can create and manage user accounts, assign realm roles, organise teams into groups, and pull identities in bulk from an LDAP or Active Directory provider. All identity operations are backed by Keycloak, so every change is durable and immediately reflected across the workspace.

How it works

Oryn's backend exposes identity management through two API controllers โ€” IdentityController (user, role, and LDAP endpoints at /api/v1/identity) and OrganisationsController (org lifecycle at /api/v1/organisations) โ€” both of which delegate to a KeycloakAdminClient. The client authenticates to Keycloak's Admin REST API using the configured admin credentials, caches the resulting bearer token until it nears expiry, and then issues signed requests against the configured realm. Every endpoint first checks the caller's X-Oryn-Admin-Role header; only requests carrying the owner, security, or org-admin role value are allowed through. Tenant-scoped requests can also be validated by decoding an org_id claim from the caller's JWT, ensuring users see only their own organisation's data unless they hold an admin role.

What you can do

List usersRetrieve up to 200 Keycloak users in the realm, including name, email, and enabled status.
Create userProvision a new user account with email, first/last name, and an optional temporary password the user must change on first login.
Update userChange a user's email, name, or enabled/disabled status in place.
Delete userPermanently remove a user account from the Keycloak realm.
Assign realm roleGrant a named Keycloak realm role (e.g. workspace-admin, developer) to any user by their user ID.
Create groupAdd a new Keycloak group to logically organise users into teams or departments.
List groupsEnumerate up to 200 groups in the realm.
Update / delete groupRename or remove an existing group.
Group membershipAdd or remove individual users from any group.
LDAP / AD full syncTrigger a full synchronisation from a configured LDAP storage provider; returns the count of accounts added or updated.
Create organisationAdmins can create a new tenant organisation record with a name, URL slug, and optional billing email.
List organisationsAdmins see all organisations; tenant-scoped callers see only their own organisation, resolved from their JWT org_id claim.

How to use it

  1. Confirm you hold an admin role
    Every identity and organisation endpoint checks the X-Oryn-Admin-Role request header. Your token must carry the value owner, security, or org-admin. If you receive a 401 workspace-admin-required error, contact whoever issued your credentials to have the correct role assigned.
  2. List existing users
    Send GET /api/v1/identity/users with your bearer token and the X-Oryn-Admin-Role header. You will receive an array of user objects โ€” each with an id, username, email, firstName, lastName, and enabled flag โ€” up to a maximum of 200 entries.
  3. Create a new user
    POST /api/v1/identity/users with a JSON body containing email, firstName, lastName, and optionally tempPassword. If tempPassword is provided, Keycloak marks it as temporary so the user is forced to set their own password at first login. On success you receive the new user's Keycloak UUID.
  4. Assign a role to the user
    POST /api/v1/identity/users/{userId}/roles/{roleName} using the UUID returned in the previous step and the exact Keycloak realm role name you want to grant. The backend fetches the role definition from Keycloak and applies it as a realm role mapping in one call.
  5. Organise users into groups
    Create a group via POST /api/v1/identity/groups (name in the body) to get a group ID. Then add members with PUT /api/v1/identity/users/{userId}/groups/{groupId}. Groups are logical containers; access policies based on groups are configured in Keycloak directly.
  6. Sync from LDAP / Active Directory
    If you have an LDAP user-storage provider configured in Keycloak, trigger a full sync with POST /api/v1/identity/ldap/{providerId}/sync. The response body contains a synced count representing the total accounts added or updated in this run.
  7. Create an organisation
    POST /api/v1/organisations with a JSON body containing name, slug, and an optional billingEmail. Only callers with an admin role can create organisations; the new record is immediately persisted and returned with a generated UUID.

Example

An admin wants to onboard a new engineer. They POST to /api/v1/identity/users with body {"email": "alex@example.com", "firstName": "Alex", "lastName": "Kim", "tempPassword": "Change-Me-123!"} โ€” headers include Authorization: Bearer <admin-token> and X-Oryn-Admin-Role: org-admin. Oryn provisions the account in Keycloak and returns {"user_id": "f4a1..."}. The admin then POSTs to /api/v1/identity/users/f4a1.../roles/developer to grant the developer realm role. Alex can now log in, will be prompted to set a permanent password, and immediately has the developer role active in the workspace.

Admin notes

Role gate: every endpoint (users, roles, LDAP sync, org creation) requires the X-Oryn-Admin-Role header to be one of owner, security, or org-admin. Requests missing this header or carrying any other value receive a 401 with error "workspace-admin-required". Keycloak connection is configured via KeycloakAdminOptions โ€” set BaseUrl, Realm, AdminUser, and AdminPassword in your server config or environment; never commit these values to source control. The admin client caches its service token and refreshes it 30 seconds before expiry, so short network outages between token renewals are tolerated. User listing and group listing are each capped at 200 results per request; for larger directories, rely on the LDAP sync rather than manual enumeration. The LDAP sync endpoint only triggers a full sync (triggerFullSync action); incremental/delta sync is not currently exposed through this API and must be scheduled in Keycloak directly. Tenant-scoped callers (those without an admin role) can only read their own organisation record, resolved from the org_id, organisationId, orgId, or organisation_id claim in their JWT.

Related