تسجيل الدخول الموحّد (SSO)

Single Sign-On Configuration

بوابة دخول واحدة لجميع تطبيقاتك — قلّل من إرهاق كلمات المرور ووفّر سياسات وصول مركزية.

نظرة عامة

SSO يسمح للمستخدمين بتسجيل الدخول مرة واحدة والوصول إلى عدة تطبيقات دون إعادة إدخال كلمات المرور. ميثاق يدعم SSO عبر:

OIDC / OAuth 2.0

البروتوكول المفضل للتطبيقات الحديثة — خفيف ومبني على JSON

SAML 2.0

للبيئات المؤسسية — SAP, Salesforce, Microsoft stack

Kerberos / LDAP

للمصادقة من Active Directory — داخل المؤسسة

WebAuthn / FIDO2

للمصادقة بدون كلمة مرور — أكثر أماناً

إنشاء Realm جديد

Realm هي وحدة العزل — كل organization أو فريق يجب أن يكون له realm خاص به.

  1. اذهب إلى Admin ConsoleCreate realm
  2. أدخل Realm name (e.g., acme-corp)
  3. أدخل Display name (e.g., ACME Corporation)
  4. فعّل Enabled
  5. اختر Login theme (branding للحساب)
  6. انقر Create

خيارات Realm المهمة

الإعدادالغرض
Registrationتفعيل/إلغاء تسجيل المستخدمين الجدد
Login with Emailالسماح بتسجيل الدخول بالبريد بدلاً من username
Forgot Passwordتفعيل رابط استعادة كلمة المرور
Remember Meتمديد Session duration تلقائياً
Edit Usernameالسماح للمستخدمين بتغيير usernames
Offline Accessتفعيل refresh tokens

تسجيل تطبيق (Client)

OIDC Client

  1. اذهب إلى ClientsCreate client
  2. Client ID: my-web-app
  3. Client Protocol: openid-connect
  4. Access Type: public (SPA) أو confidential (backend)
  5. Valid Redirect URIs: https://myapp.com/*
  6. Web Origins: https://myapp.com
  7. من Credentials: سجّل Client Secret

SAML Client

  1. Clients ← Create client ← Client type: saml
  2. Client ID: https://sf.company.com
  3. Import SP Metadata أو أدخل القيم يدوياً
  4. Configure Name ID Format و_ATTRIBUTE mappings

Client Scopes و Role Mappings

# Default Client Scopes (applied to all clients)
- openid
- profile
- email
- roles (custom scope for role claims)

# Add custom client scope
# Admin Console → Client Scopes → Create
# Name: custom-claims
# Protocol: openid-connect
# Add protocol mapper: realm roles → maps roles to token

إدارة الجلسات (Sessions)

Session_timeout

# Realm Settings → Tokens
Access Token Lifespan:       5 minutes
Access Token Lifespan For Implicit Flow: 15 minutes
Refresh Token Lifespan:      15 minutes (وقت inactivity)
SSO Session Idle Timeout:   30 minutes (تلقائي)
SSO Session Max Lifespan:   8 hours (القيمة القصوى)

Client-level Session Limits

يمكنك تحديد عدد الجلسات المتزامنة لكل مستخدم لكل تطبيق:

# Clients → [client] → Sessions
Max Sessions: 100 (القيمة القصوى)

View Active Sessions

# Admin Console: Users → [user] → Sessions
# Shows all active sessions, device info, and IP addresses

تسجيل الخروج (Logout)

Single Logout (SLO)

يسجل الخروج من جميع التطبيقات مرة واحدة:

# Logout endpoint
GET /realms/{realm}/protocol/openid-connect/logout
  ?id_token_hint=ID_TOKEN_HERE
  &post_logout_redirect_uri=https://app.com/logged-out
  &state=STATE

Front-Channel Logout

SPAs can register a front-channel logout URI:

# Clients → [client] → Front-channel logout URL
# Methaq sends GET to this URL when user logs out
Front-channel logout URL: https://myapp.com/logout

Back-Channel Logout

For confidential clients — server-to-server notification:

# Clients → [client] → Backchannel Logout URL
Backchannel logout URL: https://myapp.com/bc-logout
Backchannel Logout Session Required: ON

Identity Providers (IdPs)

يمكنك ربط ميثاق بمزود هوية خارجي — LDAP, Azure AD, Google, GitHub, SAML IdP:

إضافة Identity Provider

  1. Admin Console ← Identity Providers
  2. اختر المزود: Keycloak OpenID Connect, SAML, Google, GitHub, Azure AD, LDAP
  3. أدخل Import metadata URL أو أدخل القيم يدوياً
  4. Configure Sync Mode: import (ميثاق is source of truth) أو override (IdP is source)
  5. فعّل Store Token لتخزين tokens الخارجية

LDAP Configuration

# Identity Provider → LDAP
Vendor: Active Directory
Connection URL: ldap://ldap.company.com:389
Bind DN: CN=admin,OU=Users,DC=company,DC=com
Bind Credential: **********

User Account LDAP Attributemapping:
  LDAP Attribute         →   Methaq Attribute
  sAMAccountName         →   username
  mail                   →   email
  displayName            →   displayName
  memberOf               →   groups