CodamAIDocs
Topicdone

What happens on completion

Provisioning in a fixed order: determine initial roles, enable the account, create or assign the tenant, grant roles, welcome email.

Variants
new tenantexisting tenant (static)existing tenant (dynamic)without tenanterror → FAILED

What this is about

Once the address is verified and, if needed, the registration is approved, provisioning starts. Only now is everything created that the person needs to work: an enabled account, a tenant, a membership, roles. At the end comes the welcome email.

The steps

Provisioning (state PROVISIONING)
  1. 1
    CIAS
    determines the initial roles from the rule set; after that, hooks may change them (onAssignInitialRoles)
  2. 2
    CIAS→Keycloak
    checks that each of these roles exists
    one is missing: FAILED
  3. 3
    CIAS→Keycloak
    only for a new account: mark the address as verified, enable the account, require “set password”
  4. 4
    CIAS→Keycloak
    tenant: create a new one or assign an existing one, see below
  5. 5
    CIAS→Keycloak
    grants the initial roles, in the tenant or globally
  6. 6
    Hook
    onCompleted: CIAS creates the user record and adds the person to default groups, plus your own hooks
  7. 7
    CIAS
    registration → COMPLETED
  8. 8
    CIAS→Email
    welcome email, for a new account ideally with a link to set the password
    Result: The person can sign in

The welcome email is the last step. If only the email fails, the registration is still completed.

The tenant in the variants

How the person gets to their tenant

When: Assignment CREATE_NEW, for example in self-registration.

  1. 1
    CIAS→Keycloak
    creates the organization: alias = tenant key, name = company field
  2. 2
    CIAS
    creates the tenant, kind DYNAMIC, with a reference to the organization. With MULTI, the tenant's database is also provisioned in this step
  3. 3
    CIAS→Keycloak
    makes the person a member of the organization
  4. 4
    CIAS→Keycloak
    sets the attributes tenant and allowedTenants on the account

Result: The person is the founder of the new tenant. Roles of the TENANT_FOUNDER situation.

When: The tenant has no organization.

CIAS sets the attributes tenant and allowedTenants on the account. Nothing more is needed: for a static tenant, the attribute is the membership. The roles are granted globally.

Result: Roles of the TENANT_MEMBER situation.

When: The tenant has an organization in Keycloak.

CIAS sets the attributes and makes the person a member of the organization. The roles are granted in the organization and so end up in the token's organization claim.

Result: Roles of the TENANT_MEMBER situation.

When: Assignment NONE.

No tenant, no membership. The roles are granted globally.

Result: Roles of the TENANTLESS situation.

CIAS checks in this step whether an existing tenant exists. If it does not, the registration ends in FAILED.

When something goes wrong

Errors in provisioning
What fails?Consequence
an initial role does not existFAILED. Create the role, then retry
Keycloak not reachableFAILED, response 503. retry later
the named tenant does not existFAILED. Create the tenant or discard the registration
one of your own hooks throws an exceptionFAILED. Fix the cause, then retry
a rule for the initial roles cannot be evaluatedFAILED. Repair the rule, then retry
the tenant key now belongs to another tenantFAILED, response 422 cias.registration.tenant-key-taken. Discard the registration
only the welcome emailCOMPLETED, the email is missing

With FAILED, the request that triggered provisioning gets an error: the click on the link or the approval. The person themselves gets no email. A platform administrator finds the registration in the list with state=FAILED and can repeat it with retry or discard it with discard. See Approval by an administrator.

New tenant: retrying and taking back

Creating a new tenant (CREATE_NEW) produces things a second attempt already finds. So the registration remembers the organization it created in Keycloak as soon as it exists.

  • retry continues. It takes the remembered organization and the tenant attached to it instead of creating both a second time. If only the tenant’s provisioning failed, it starts that again.
  • Nothing foreign is adopted. The tenant key is checked at registration but not reserved. If an organization the registration did not create now sits under it, retry refuses. Otherwise the founder would become the owner of a stranger’s tenant.
  • discard takes things back. See Cleanup.

Next

Sources in the code and the knowledge base
  • CIAS/cias-registration – RegistrationService (provision, assignTenant, grantRoles, requireRolesExist, passwordSetupContext)
  • CIAS/cias-tenancy – TenantService (createTenant)
  • CIAS/cias-iam-keycloak – KeycloakIdentityAdapter, KeycloakOrganizationAdapter, KeycloakRoleAdapter
  • CIAS/cias-spring-boot-starter – RegistrationUserHook, RegistrationDefaultGroupHook
  • CIAS/cias-registration/docs/adr – ADR-011, ADR-029
Search