Appearance
Realm Configuration Reference
This page documents the OIDC configuration, client IDs, token lifetimes, and authentication flow settings for both Keycloak realms used in Microtec ERP.
Realm Overview
microtec Realm
Realm-Level Settings
| Setting | Value | Notes |
|---|---|---|
| Realm ID | microtec | Cannot change after creation |
| Display Name | Microtec ERP | Shown on login page |
| Enabled | true | — |
| Login Theme | microtec-rtl | Custom RTL-aware theme |
| Account Theme | microtec-rtl | — |
| Email Theme | microtec-email | Branded email templates |
| Default Locale | ar | Arabic |
| Supported Locales | ar, en | |
| Registration Allowed | false | Self-registration disabled |
| Forgot Password | true | Via email OTP |
| Remember Me | true | 30-day persistent session |
Token Lifetime Settings
| Token Type | Lifetime | Notes |
|---|---|---|
| Access Token | 1800s (30 min) | Short-lived for security |
| Refresh Token | 28800s (8 hrs) | Renewed on each use |
| SSO Session Max | 36000s (10 hrs) | Working day coverage |
| SSO Session Idle | 7200s (2 hrs) | Inactivity timeout |
| Offline Session Max | 5184000s (60 days) | Mobile apps |
| Client Session Max | 3600s (1 hr) | Per-client override possible |
Client Registrations (microtec)
All 9 MFE apps register as public OIDC clients (no client secret — browser apps cannot keep secrets) in the microtec realm:
| Client ID | Port | Redirect URIs |
|---|---|---|
erp-home | 4401 | {domain}/erp-home/*, http://localhost:4401/* |
apps-accounting | 4402 | {domain}/accounting/*, http://localhost:4402/* |
apps-hr | 4403 | {domain}/hr/*, http://localhost:4403/* |
apps-finance | 4404 | {domain}/finance/*, http://localhost:4404/* |
apps-sales | 4405 | {domain}/sales/*, http://localhost:4405/* |
apps-purchase | 4406 | {domain}/purchase/*, http://localhost:4406/* |
apps-inventory | 4407 | {domain}/inventory/*, http://localhost:4407/* |
app-distribution | 4408 | {domain}/distribution/*, http://localhost:4408/* |
fixed-assets | 4409 | {domain}/fixed-assets/*, http://localhost:4409/* |
Domain by Environment
Replace {domain} with the environment-specific domain:
| Env | Domain |
|---|---|
| dev | https://microtec-test.com |
| stage | https://microtecstage.com |
| uat | https://microtec-uat.com |
| prod | https://onlinemicrotec.com.sa |
OIDC Flow Configuration per Client
All microtec realm clients use the same flow settings:
json
{
"protocol": "openid-connect",
"publicClient": true,
"standardFlowEnabled": true,
"implicitFlowEnabled": false,
"directAccessGrantsEnabled": false,
"serviceAccountsEnabled": false,
"authorizationServicesEnabled": false
}Direct Access Grants Disabled
directAccessGrantsEnabled is false on all browser clients. This prevents password grants (no OAuth2 password flow). This is intentional — browser apps must use the authorization code + PKCE flow.
Default Client Scopes (microtec)
Every client in the microtec realm automatically receives these scopes:
| Scope | Claims Added to Token |
|---|---|
openid | Standard OIDC claims |
profile | name, given_name, family_name, picture |
email | email, email_verified |
roles | realm_access.roles, resource_access.{client}.roles |
tenant | tenantId, tenantName (custom scope via seeding SPI) |
locale | locale (ar/en) |
businessowner Realm
Realm-Level Settings
| Setting | Value | Notes |
|---|---|---|
| Realm ID | businessowner | — |
| Display Name | Microtec Business Portal | — |
| Login Theme | microtec-bo | Different theme, LTR-first |
| Default Locale | en | English default for BO portal |
| Supported Locales | ar, en | — |
| Registration Allowed | false | Invite-only; accounts created by admins |
| Forgot Password | true | — |
Token Lifetime Settings
| Token Type | Lifetime | Difference from microtec realm |
|---|---|---|
| Access Token | 3600s (1 hr) | Longer (admin tasks take more time) |
| Refresh Token | 28800s (8 hrs) | Standard work session |
| SSO Session Max | 28800s (8 hrs) | — |
| SSO Session Idle | 3600s (1 hr) | — |
Client Registrations (businessowner)
| Client ID | Port | Purpose |
|---|---|---|
bussiness-owners | 4301 | Business Owner portal |
bo-mobile | — | BO mobile app (if enabled) |
bo-backend-service | — | Confidential client for backend calls |
bussiness-owners Spelling
The client ID bussiness-owners (double-s) is intentional — it matches the Angular project name in FrontApps/projects/. Do NOT correct the spelling as it would require renaming the Angular workspace and all Keycloak configurations.
OIDC Configuration (businessowner)
json
{
"clientId": "bussiness-owners",
"protocol": "openid-connect",
"publicClient": true,
"standardFlowEnabled": true,
"directAccessGrantsEnabled": false,
"redirectUris": [
"https://businessowner.{domain}/*",
"http://localhost:4301/*"
],
"webOrigins": ["*"]
}Authentication Flow Priority
Both realms (microtec and businessowner) use the same customized browser flow. Priority determines execution order within each ALTERNATIVE step group.
| Priority | Authenticator | Config |
|---|---|---|
| 10 | Multi-Account Cookie (MAC) | kc.MAC.encryptionKey set |
| 20 | Cookie | Default config |
| 30 | Identity Provider Redirector | defaultProvider not set |
Backchannel Logout
Backchannel logout (RFC 7009 + OIDC Session Management) is implemented in both realms. When a user logs out from any app:
- Keycloak sends a
POSTlogout request to each registered client'sbackchannelLogoutUrl - Each Angular app clears its local session/token storage
- The MAC cookie is cleared via the multi-account SPI
Backchannel logout URL pattern per app:
https://{domain}/{app-path}/auth/backchannel-logoutAlready Implemented
Backchannel logout is already coded and verified in the frontend shared-lib (FrontApps/libs/shared-lib/src/lib/auth/). No additional configuration required.
Role Structure
microtec Realm Roles
realm roles:
├── erp-user # Base role for all ERP users
├── erp-admin # Module administration
├── tenant-owner # Company owner, can manage users
├── system-admin # Cross-tenant admin (Microtec staff)
└── readonly-user # View-only access
client roles (per app):
apps-accounting:
├── accounting-user
├── accounting-manager
└── accounting-viewerbusinessowner Realm Roles
realm roles:
├── bo-user # Standard BO portal user
├── bo-admin # Full BO admin
├── support-agent # Microtec support staff
└── readonly # Reporting/audit accessRelated Documentation
- Keycloak Overview — Deployment, SPI list, flow priority
- Multi-Account SPI — MAC cookie details
- Seeding SPI — How these configurations are provisioned
- Frontend Auth — Angular Keycloak integration