Implementing web embed interfaces
4 Tasks
1 hr 30 mins
Scenario
Metro Delivery Company (MDC) is a B2B company that specializes in delivering same-day, intra-city shipments from registered business partners to their destinations. To support their expansion, the company wants to automate specific business operations using Pega Platform™, including:
- Business Partner Registration
- Truck Vendor Registration
Business Partners can register directly on the MDC website to use delivery services by purchasing a membership with a price plan. After registration approval and payment completion, Business Partners can log in to the Delivery Service application to schedule shipments. The following information is collected:
- Business partner name
- Salutation
- First name
- Last name
- Primary email
- Primary phone number
- Address
- Membership type
- Pricing model
MDC offers membership types including Bronze, Silver, and Gold, with registration costs varying by membership type. Registration requests are sent to the executive manager for approval.
Trucks are procured exclusively from registered vendors. The MDC website provides an option for truck vendors to register if they wish to provide truck services for product shipping and delivery in specific cities. The truck vendor registration process requires the following details:
- Truck company Name and Address
- Contact Name, Phone and Email
- City in which services can be provided (more than one city can be specified)
- Minimum number of trucks that can be provided daily in each city (the capacity of each truck is always 64 units, subject to change in the future)
- VIN (Vehicle Identification Number)) of each truck
- Type of contract of Daily assignment: a company is contacted to supply up to a specified minimum number of trucks in each city, each day (automated assignment).
The following table provides the credentials you need to verify the solution:
| Role | User name | Password |
|---|---|---|
| Admin | admin@deliveryservice | rules |
Detailed Tasks
1 Identify Design options
The web embed can be built by using either:
- the Create a case action, or
- the Display a page action.
2 Evaluate Design options
Option 1: Use the Create a case action (Recommended)
The Create a case action provides all the necessary case management features, including pre-processing, post-processing, and validation, which are all available in the case configuration. Additionally, data can be persisted across multiple data objects with transaction consistency.
Option 2: Use the Display page action
Display page actions present information only. Data collected for vendors or business partners spans multiple data objects, such as address and contact details. The default DX APIs allow data entry only for top-level data objects. The default landing page layout displays multiple records in a table, which can expose other users’ registration details and create a data security risk. Business partner registrations require approval from an executive manager.
3 Review Solution details
To create a case for web embed, you first download the MDCSample.zip file from the Rule-File-Binary, as shown in the following figure:
Extract MDCSample.zip to the opt/tomcat/webapps directory of VM system, and then launch the Pega WebEmbed with <cite>http://<host>:<port>/MDCSample/</cite>.
The HTML files in the unzipped MDCSample directory can be opened directly. The index.html file is opened first when accessed by a web server such as Tomcat. You can also click BusinessPartner.html and TruckVendor.html directly.
You use the WebEmbed Channel interface configuration in Dev Studio or App Studio to generate the WebEmbed code for Partner and Vendor Enrolment Case Types. Embed the generated code in the BusinessPartner.html and TruckVendor.html files. Business Partner Registration launches the Business Partner registration case. Truck Vendor Registration launches the Truck Vendor Registration case. The cases can be launched by clicking in the upper-right corner of the workspace.
Web embed authentication
Authentication ensures that only users and systems with a verified identity can use the WebEmbed, and that all permitted manipulations of the data occur under the current user identity.
In earlier versions of Pega Platform, for mashups the Anonymous Authentication Service (AAS) was used to establish authentication. However, this is not supported in Constellation-based web embeds.
Configuring authentication for web embeds
For Web Embeds there are three types of Authentication mechanisms available:
-
Authorization code
When using the Authorization code grant flow, OAuth is utilized, and the Alias of a Custom Authentication Service must be specified. In this scenario, the OAuth authorization code grant flow still occurs, but custom activity governs which operator is eventually mapped to. The custom activity code needs to have logic to dynamically create external operators. Note that when generating web embed channels, such custom authentication services do not appear in the drop-down menu. The custom authentication service rule should include an activity that takes inputs to the request, such as cookies, and maps them to a specific dynamic operator, or rejects the request. The activity should interact with Pega OAuth 2.0 grant flow or interact with external identity access providers to authenticate the user.
-
Custom bearer
Uses OAuth and the new Custom Bearer public grant flow, which also uses custom activity logic to determine the operator (so that there are no redirects).
-
None (Custom)
Does not use an OAuth grant flow, but instead specifies the explicit authHeader to use (grantType="none").
Authentication of the WebEmbed is handled using OAuth2.0. For more information, see Authentication in web embed.
The steps for custom bearer configuration are as follows:
Step 1: Create the dynamic system settings (DSS)
Once the grant type is configured, create a DSS named CustomAuthForPegaEmbed in the Pega-Engine Ruleset and enter True in the Value field. This enables custom bearer authentication for the web embed.
Step 2: Configure authentication on the Web embed
The Constellation web embed only supports OAuth 2.0. To configure authentication on the web embed, in App Studio, click to configure a new web embed, or click to view existing web embeds.
When the web embed configuration opens, the Grant Type drop-down list is displayed. Because there is no identity provider system in place, we use the custom bearer option in the Grant Type.
After clicking , the code includes a ClientID field that is unique to each web embed.
Step 3: Update the Client to accept the Custom bearer
After saving the web embed configuration, an OAuth client registration is generated. Switch to Dev Studio and open the client registration for the web embed from the . When the client registration Rule opens, under ,ensure that the Custom Bearer checkbox is selected.
Step 4: Update the client registration with utility to identify the operator
After selecting the Custom Bearer checkbox, an activity needs to be created to set the operator details. Based on the client ID, a specific operator must be mapped. The client ID can be mapped from the postBodyContent parameter. Once the client ID is parsed from the parameter, a decision table can be used to fetch the operator profile. The operator instance must be copied to the pyOperPage page, which is then passed as a parameter and processed by the authentication engine. See the pyPegaOAuthAccessTokenAuthenticationActivity activity for more information.
Step 5: Update the oAuth2.0 service package to point to the application-specific access group
By default, the OAuth Service package points to the Pega Platform application. The service access group must be updated to point to our application. Access to the application is controlled through the access group and the AROs.
4 Debugging web embed authentication
The Service REST named token can be used to debug web embed authentication, and service monitoring can be turned On or Off based on requirements. The service request history is maintained in the service package, and requests can be viewed by clicking . If necessary, you can trace the token service Rule in Pega-IntegrationEngine ruleset to debug authentication issues in the web embed.
Available in the following mission:
Want to help us improve this content?