|
| 1 | +# Keycloak Configuration for Licensing Project |
| 2 | + |
| 3 | +This document describes the **Licensing Realm** configuration in Keycloak that powers the licensing framework. It covers the demo realm, users, attributes, and groups used to store license information. This setup is required to ensure that the **Licensing Service** can issue and validate tokens against user license metadata. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Accessing Keycloak |
| 8 | + |
| 9 | +* **URL**: [http://localhost:8180/](http://localhost:8180/) |
| 10 | +* **Admin credentials** (demo only): |
| 11 | + |
| 12 | + * Username: `licensing-admin` |
| 13 | + * Password: `admin123` |
| 14 | +* **Realm**: `licensing-realm` |
| 15 | + |
| 16 | +Once logged in, switch to `licensing-realm` via **Manage Realms**. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Demo User |
| 21 | + |
| 22 | +A sample user is pre-configured for testing: |
| 23 | + |
| 24 | +* **Username**: `license-demo-user` |
| 25 | +* **Email**: `licensedemouser@example.com` |
| 26 | +* **User ID**: `3ddfdf87-ddb3-43b3-8926-35d114aef39b` |
| 27 | +* **License Tier**: `Professional` |
| 28 | +* **License Status**: `Active` |
| 29 | +* **License Expiration**: `2027-05-14T17:34:00` |
| 30 | +* **Max Count**: `20` |
| 31 | +* **Remaining Usage Count**: `19` |
| 32 | +* **Allowed Services**: `crm`, `billing`, `reporting` |
| 33 | +* **Allowed Service Versions**: |
| 34 | + |
| 35 | + * crm ≤ 1.5.0 |
| 36 | + * billing ≤ 2.0.0 |
| 37 | + * reporting ≤ 1.0.3 |
| 38 | +* **Checksums**: |
| 39 | + |
| 40 | + * crm: `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8a5` |
| 41 | + * billing: `2c7700c37f1fca44b4494a82c4d422a2c40e0c3a7e3e8a5b27b43c4d9242c771` |
| 42 | + * reporting: `f42a77784d4cca7f3b0c848929b0febf2c2f4a82e1a13fda29b334af508e2c0f` |
| 43 | +* **Instance IDs**: `licensing-service~demo~00:11:22:33:44:55` |
| 44 | + |
| 45 | +### Demo User in Keycloak (Screenshots) |
| 46 | + |
| 47 | +Below screenshots illustrate how the demo user (`license-demo-user`) is configured in Keycloak. |
| 48 | + |
| 49 | +**General Section** |
| 50 | + |
| 51 | + |
| 52 | +**License Details** |
| 53 | + |
| 54 | + |
| 55 | +**Service Details** |
| 56 | + |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## License Attributes |
| 61 | + |
| 62 | +The following custom attributes are used to store license metadata in Keycloak. |
| 63 | + |
| 64 | +| Attribute | Group | Type | Example Value(s) | |
| 65 | +| ------------------------ | --------------- | ------------ | ------------------------------------------------------------------ | |
| 66 | +| `licenseTier` | license-details | Enum | `Starter`, `Professional`, `Enterprise` | |
| 67 | +| `licenseStatus` | license-details | Enum | `Active`, `Inactive`, `Trial`, `Suspended`, `Expired` | |
| 68 | +| `licenseExpiration` | license-details | DateTime | `2027-05-14T17:34:00` | |
| 69 | +| `maxCount` | license-details | Integer | `20` | |
| 70 | +| `remainingUsageCount` | license-details | Integer | `19` | |
| 71 | +| `allowedServices` | service-details | Multi-Select | `crm`, `billing`, `reporting` | |
| 72 | +| `allowedServiceVersions` | service-details | JSON | `{ "serviceId": "crm", "licensedMaxVersion": "1.5.0" }` | |
| 73 | +| `checksumCrm` | service-details | String | `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8a5` | |
| 74 | +| `checksumBilling` | service-details | String | `2c7700c37f1fca44b4494a82c4d422a2c40e0c3a7e3e8a5b27b43c4d9242c771` | |
| 75 | +| `checksumReporting` | service-details | String | `f42a77784d4cca7f3b0c848929b0febf2c2f4a82e1a13fda29b334af508e2c0f` | |
| 76 | +| `instanceIds` | service-details | Multi-Value | `licensing-service~demo~00:11:22:33:44:55` | |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Attribute Groups |
| 81 | + |
| 82 | +Attributes are organized into logical groups: |
| 83 | + |
| 84 | +* **User Metadata**: Standard Keycloak user metadata (`firstName`, `lastName`, `email`, etc.) |
| 85 | +* **License Details**: License-related metadata such as tier, status, expiration, and usage counts. |
| 86 | +* **Service Details**: Service-level entitlements, allowed versions, checksums, and bound instance IDs. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Usage in Licensing Service |
| 91 | + |
| 92 | +* The **Licensing Service** queries Keycloak for user attributes when validating a license key. |
| 93 | +* Attributes like `licenseExpiration`, `licenseStatus`, and `allowedServices` are enforced during token issuance. |
| 94 | +* Checksums and instance IDs provide request-level integrity validation. |
| 95 | + |
| 96 | +--- |
0 commit comments