Dear @MadhuSudan_Kaka ,
Custom Approach: Issuing JWT Bearer Tokens for Non-Existent Operators
Background / Problem Statement
As far as I’m aware, Pega does not currently offer an out-of-the-box (OOTB) supported pattern to issue JWT Bearer tokens when the corresponding Operator ID does not already exist in the system. I raised a support ticket with Pega on this specific scenario, and their response confirmed that no such supported pattern exists today.
Given this gap, I implemented a custom approach — conceptually aligned with the design discussed above — to handle JWT Bearer token issuance for cases where the Operator record needs to be dynamically provisioned at authentication time, rather than pre-provisioned in advance.
Solution Overview
The core idea is to leverage the standard Identity Mapping and Claims processing flow, but extend the post-processing logic to check for Operator existence and provision the Operator on-the-fly if it’s not found, before completing the authentication context.
Detailed Steps
- Token Reception
The JWT is received from the client system as part of the Bearer token authentication request. - Token Validation (Identity Mapping)
Within the Identity Mapping rule, complete the standard token validation — signature verification, expiry, issuer, and audience checks as per your configured Authentication Service. - Token Profile Processing
Process the token profile through the standard sequence:- Claims Validation — verify the required claims are present and well-formed.
- Claims Mapping — map the incoming JWT claims to the
claimsMappingPagestructure. - Security Check — apply any additional security/authorization checks as configured.
- Operator Identification via Custom Claim
Since the Operator doesn’t pre-exist, map a custom claim from the token to a static/deterministic value that can be used as the Operator ID — for example,{Client Name}. This value should correspond to a Service Operator already created in Pega, which will act as the template/reference identity for provisioning. - Override Processing Activity
In the Processing options of the Identity Mapping, override the default activity with a custom activity in your application ruleset — e.g.,pyJWTBearerIdentityMappingAct. This gives you a hook to inject custom logic into the standard flow. - Retrieve Operator ID from Claims
Within the custom activity, retrieve the actual Operator ID fromclaimsMappingPage.pyUserIdentifier. This is the identifier that should represent the “real” Operator for this authenticated session. - Operator Existence Check
Perform anObj-Open(or equivalent existence check, e.g.,Obj-Open-By-Handle/Exists-In-DB) on the Operator ID retrieved above.- If the Operator exists: proceed with the standard flow.
- If the Operator does not exist: dynamically provision a new Operator record using the Model Operator as a template, populating the required attributes (Operator ID, access group, work group, etc.) from the token claims / Service Operator defaults.
- Persist the New Operator
Save the newly created Operator record to the database. - Re-establish Operator Context
After saving, perform anObj-Openon the newly created Operator record, targeting it explicitly to the “Operator” step page. This replaces the in-memory Operator page (which, up to this point, still referenced the Service Operator) with the details of the newly provisioned Operator. As a result, the JWT/session token generated by Pega at the end of the authentication flow carries the context of the newly created Operator, rather than the placeholder Service Operator used during the intermediate steps.
Outcome
This approach effectively decouples Operator provisioning from the authentication flow’s dependency on pre-existing Operator records, allowing just-in-time Operator creation driven entirely by validated JWT claims — while still working within Pega’s standard Identity Mapping and Authentication Service framework.