ModulesOrg OnboardingOverview

Org Onboarding

The Org Onboarding module handles the creation and activation of new organizations in Lacroo Pro. It provides an invite-code-protected setup wizard that walks founding administrators through configuring their organization, connecting Microsoft Entra SSO, and provisioning the initial master admin accounts.

Data Model

Organizations

ColumnTypeDescription
idUUIDPrimary key
nameTEXTDisplay name
slugTEXTURL-safe unique identifier
logo_urlTEXTOptional logo URL
erp_sourceENUMERP system integration (8 options)
entra_tenant_idTEXTMicrosoft Entra tenant
entra_client_idTEXTApp registration client ID
entra_client_secret_encryptedBYTEAAES-256-GCM encrypted secret
sso_configuredBOOLSet once SSO credentials are saved
statusENUMpending_setup, active, suspended

Users

ColumnTypeDescription
idUUIDPrimary key
org_idUUIDForeign key to organizations
entra_object_idTEXTMicrosoft Entra object ID (unique per org when set)
nameTEXTDisplay name
emailTEXTEmail (unique per org). For SSO users this is their mailbox (Graph mail), not always their sign-in name
auth_methodENUMHow the person signs in: sso (Microsoft), password, email_password or none. Routing is per user, not per org
entra_upnTEXTTheir Microsoft user principal name, when known
entra_user_typeTEXTMember or Guest, as Microsoft reports it
entra_sign_in_nameTEXTThe name they sign in to Microsoft with; sent as the sign-in hint and shown as “Signs in as”
roleENUMOne of 14 roles
statusENUMactive, inactive, pending, deleted

The three entra_* identity columns are kept true by the nightly directory refresh and by each successful Microsoft sign-in. A person’s first successful Microsoft sign-in also moves them from pending to active.

User Roles

master_admin, organisational_manager, project_admin, engineer, senior_supervisor, supervisor, labour, operator, wet_hire_machines, dry_hire_machines, subcontractor, supplier, client, unassigned

API Endpoints

MethodPathAuthDescription
POST/v1/setup/validate-inviteNoneValidate invite code
POST/v1/setup/orgSetupTokenCreate organization
POST/v1/setup/org/{orgId}/logoSetupTokenUpload org logo
POST/v1/setup/org/{orgId}/adminSetupTokenCreate founding admin
PUT/v1/setup/org/{orgId}/ssoSetupTokenStore SSO config
POST/v1/setup/org/{orgId}/sso/validateSetupTokenValidate SSO + list users
POST/v1/setup/org/{orgId}/finalizeSetupTokenCreate co-admin + activate
GET/v1/orgs/{orgId}/dashboardBearerAuthGet org dashboard

Security

  • Setup tokens are short-lived JWTs (HS256) that bind each wizard session to an invite code and (after org creation) an organization.
  • Client secrets are encrypted with AES-256-GCM before storage. The encryption key is configured via AES_ENCRYPTION_KEY env var (64-char hex string).
  • Invite codes gate access to the setup wizard. Each code tracks usage count.
  • Internal service auth — All /v1/auth/* endpoints require X-Internal-Service-Key header. Only the BFF can call them.
  • Tenant isolation — All user queries include AND org_id = $N. Dashboard/delete endpoints verify JWT org_id matches the requested org.
  • Double input validation — Zod schemas at the BFF layer + Go struct validation with net/mail email parsing and length limits.
  • Session management via Go API — The BFF never touches PostgreSQL directly. Session creation, validation, and deletion all go through the Go API.
  • httpOnly cookies — All lacroo.* cookies (session_token, org_id, role) are httpOnly to prevent client-side JS access.
  • Log redaction — Sensitive fields (password, token, secret, etc.) are automatically redacted in structured logs.
  • Request body limit — 1MB global max body size to prevent payload abuse.