<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christian Brindley on Medium]]></title>
        <description><![CDATA[Stories by Christian Brindley on Medium]]></description>
        <link>https://medium.com/@christian.brindley?source=rss-53dada6f78f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*csdkxcwKmu8Iz9PujbDYDQ.jpeg</url>
            <title>Stories by Christian Brindley on Medium</title>
            <link>https://medium.com/@christian.brindley?source=rss-53dada6f78f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:04:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christian.brindley/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PingOne Advanced Identity Cloud: Essentials for building a custom journey UI]]></title>
            <link>https://medium.com/@christian.brindley/pingone-advanced-identity-cloud-essentials-for-building-a-custom-journey-ui-f43b89b83ab0?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f43b89b83ab0</guid>
            <category><![CDATA[pingone-aic]]></category>
            <category><![CDATA[ping-identity]]></category>
            <category><![CDATA[forgerock]]></category>
            <category><![CDATA[forgerock-identity-cloud]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 12:59:09 GMT</pubDate>
            <atom:updated>2026-10-12T12:59:09.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*-nH6te0aLGYmKWM-NNMiYA@2x.jpeg" /></figure><p>The <a href="https://docs.pingidentity.com/pingoneaic/getting-started/overview.html">PingOne Advanced Identity Cloud</a> platform (and the <a href="https://docs.pingidentity.com/pingam/latest/index.html">self managed software equivalent</a>) allows customers to build any user journey, from registration to login and anything beyond.</p><p>The platform includes a built in journey UI which adapts to the logic you implement via the <a href="https://docs.pingidentity.com/pingoneaic/journeys/journeys.html">Journey Designer</a>. This UI is highly configurable, with extensive theming and locale friendly messaging. However, particularly for <a href="https://www.pingidentity.com/en/resources/blog/post/what-is-customer-identity-and-access-management-ciam.html">CIAM</a> use cases, customers often want to develop their own UI for integration into the customer facing application environment.</p><p>When developing a journey UI, you should use the <a href="https://developer.pingidentity.com/orchsdks/journey/index.html">Ping Orchestration SDK</a> to accelerate integration with the Ping platform. This allows you to focus on the user experience and branding aspects of each journey, while the SDK handles the interaction with the Ping backend authentication API.</p><p>In this article, we are going to cover the following aspects of any well designed journey UI:</p><ul><li><strong>Generating Transaction IDs</strong></li><li><strong>Handling inbound URL parameters</strong></li><li><strong>Navigating journey stages</strong></li><li><strong>Handling user facing messages</strong></li><li><strong>Handling successUrl and failureUrl at the end of a journey</strong></li><li><strong>Handling journey timeout</strong></li></ul><p>This article is focused on the standalone web based journey UI; however some of these principles apply equally to a mobile or web app with embedded Ping journeys.</p><h4>Architecture</h4><p>Before launching into the details, it is worth summarising the architecture of a web based journey UI for the Ping platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0Zt84F9lWyG8YVslJvDRg.png" /></figure><p>The web UI is implemented as a JavaScript <a href="https://developer.mozilla.org/en-US/docs/Glossary/SPA">Single Page Application</a>, using a framework such as <a href="https://react.dev/">React</a> or <a href="https://angular.dev/">Angular</a>. The journey logic is implemented on the Ping backend; the UI delivers the presentation layer on top of this logic. The UI interacts with the <strong>/authenticate</strong> endpoint on the Ping backend: this endpoint instructs the UI what input data is required for each step of the journey, in the form of <a href="https://docs.pingidentity.com/pingoneaic/am-authentication/callbacks-supported.html">callbacks</a>. If this is an authentication journey (as opposed to registration, forgotten password etc) the final response from the backend includes a session cookie and URL forwarding instruction.</p><h4>Sample applications</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtozhOIzgNuu_64F0E3nJg.png" /></figure><p>The Ping SDK includes a <a href="https://github.com/ForgeRock/sdk-sample-apps/tree/main/javascript/reactjs-todo-oidc">sample application</a> with a built in login UI. This is a good starting point for developing your own journey UI. Note that the sample app is not a direct equivalent of a standalone journey UI: it is an OIDC enabled application which includes login journey handling. For a standalone journey, you need to implement only the journey handling part of the sample app, and ignore the OIDC logic.</p><p>Another useful reference is the <a href="https://github.com/ForgeRock/platform-ui/tree/master/packages/platform-login">public source repo</a> for the built in platform UI. This incorporates all of the concepts covered in this article.</p><h3>Generating transaction IDs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jyKamd5tej-b7RuF.png" /></figure><p>When making calls to the backend authentication service, it is good practice to include the <a href="https://docs.pingidentity.com/pingoneaic/tenants/audit-debug-logs-pull.html#view-logs-for-a-specific-request"><strong>x-forgerock-transactionid</strong></a> header:</p><pre>POST https://openam-demo.forgeblocks.com/am/json/realms/root/authenticate?goto=....<br>...<br>x-forgerock-transactionid: f264997f-ea21-4433-b8b6-9546c190fad2-request-2<br>...</pre><p>This transaction id is included in all related audit and debug logs on the backend, allowing you to correlate all events for a particular journey.</p><p>If you do not supply the <strong>x-forgerock-transactionid</strong> header, the backend generates a unique and separate transaction id for every call to the authentication service. This makes it very hard to follow a journey end to end in the audit trail, and hard to debug issues which occur earlier or later in the journey.</p><p>When your UI initiates a journey, seed the transaction ID by generating a random <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">uuid</a> (or use an inbound correlation id such as a <a href="https://openid.net/specs/openid-financial-api-part-1-wd-01.html">FAPI interaction id</a>) together with a counter as a suffix: the suffix is incremented at each step to provide a clear journey sequence in the backend audit trail.</p><p>Use a middleware function to inject the <strong>x-forgerock-transactionid</strong> header into each request to the authenticaiton service, increment the counter each time. The <a href="https://github.com/ForgeRock/platform-ui/tree/master/packages/platform-login">source code</a> for the in-built platform UI has an example of this:</p><pre>function getRootTransactionId() {<br>  const urlParams = new URLSearchParams(window.location.search);<br>  return urlParams.get(&#39;transactionId&#39;) ? urlParams.get(&#39;transactionId&#39;) : uuid();<br>}</pre><pre>const rootTransactionId = getRootTransactionId();<br>let authRequestNumber = 0;</pre><pre>const transactionIdMiddleware = (req, _action, next) =&gt; {<br>  authRequestNumber += 1;<br>  req.headers.append(&#39;x-forgerock-transactionid&#39;, `${rootTransactionId}-request-${authRequestNumber}`);<br>  next();<br>};</pre><pre>...</pre><pre>const requestMiddleware = [<br>  sdkTimeoutMiddleware,<br>  transactionIdMiddleware,<br>  ...(localeQueryString ? [languageMiddleware] : []),<br>];</pre><pre>...</pre><pre>const client = await journey({<br>  config: journeyConfig,<br>  requestMiddleware,<br>});</pre><p>Now you can search audit and debug logs using the base transaction ID for the end to end journey, or add the counter suffix for events related to a single stage of the journey.</p><h3>Handling inbound URL parameters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ps6ueyH2djEYwjmVw9AV-Q.png" /></figure><p>For login, the UI is typically called during an application access attempt, such as an OpenID Connect flow, or transactional/step up flow. In this case, the journey UI is called with a number of URL parameters containing the application context. These inbound URL parameters need to be passed through to the backend journey API by attaching them to the REST call to the <strong>/authenticate</strong> endpoint.</p><p>The simplest method is to pass through all of the inbound URL parameters, using an SDK <a href="https://developer.pingidentity.com/orchsdks/journey/customization/requests/javascript-request-interceptors.html">request interceptor</a>. This is added to the journey requestMiddleware, along with the other middleware for transaction IDs etc. For example:</p><pre>  const forwardedKeys = new Set([<br>    &quot;goto&quot;,<br>    &quot;gotoOnFail&quot;,<br>    &quot;authIndexType&quot;,<br>    &quot;authIndexValue&quot;,<br>    &quot;suspendedId&quot;,<br>    &quot;noSession&quot;,<br>    &quot;ForceAuth&quot;,<br>    &quot;locale&quot;,<br>  ]);<br><br>  const inboundParams = new URLSearchParams(window.location.search);<br><br>  const forwardInboundParams = (req, action, next) =&gt; {<br>    if (action.type === &quot;JOURNEY_START&quot; || action.type === &quot;JOURNEY_NEXT&quot;) {<br>      for (const key of forwardedKeys) {<br>        const values = inboundParams.getAll(key);<br>        if (!values.length) continue;<br><br>        // Replace any SDK-generated value, then preserve duplicates.<br>        req.url.searchParams.delete(key);<br>        for (const value of values) {<br>          req.url.searchParams.append(key, value);<br>        }<br>      }<br>    }<br><br>    next();<br>  };<br><br>...<br><br>  const client = await journey({<br>    config: journeyConfig,<br>    requestMiddleware: [<br>      transactionIdMiddleware,  <br>      forwardInboundParams <br>  });</pre><h3>Navigating journey stages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNrcIGNbSXFMdvcT6xmAhg.png" /></figure><p>A journey is made up of a number of steps which make up the end to end logic. Each step is either <strong>data input</strong> (i.e. callbacks for user credentials, device information etc) or <strong>backend logic</strong> (e.g. looking up user profile data, calling out to supporting services such as <a href="https://docs.pingidentity.com/pingone/threat_protection_using_pingone_protect/p1_protect_introduction.html">PingOne Protect</a>, or a third party fraud detection platform).</p><p>A data input step is a collection of one or more callbacks, which can be grouped into a <strong>stage</strong>. A stage is implemented using a journey Page Node, containing the required callback nodes for requesting information via the frontend UI. The Page Node is configured with a stage name: this is delivered to the UI along with the callbacks generated by the journey nodes within the page.</p><p>For example, let’s take a simple example of a username and password stage. The journey includes a Page node as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f85pWScPmqLy6elVFsm7_Q.png" /></figure><p>When the UI starts the journey, the backend responds with the set of callbacks for userid and password, together with the stage name as follows:</p><pre>{<br>    &quot;authId&quot;: &quot;eyJ0e...QJZI&quot;,<br>    &quot;callbacks&quot;: [<br>        {<br>            &quot;type&quot;: &quot;NameCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;User ID&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken1&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 0<br>        },<br>        {<br>            &quot;type&quot;: &quot;PasswordCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;Password&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken2&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 1<br>        }<br>    ],<br>    &quot;stage&quot;: &quot;loginUserPass&quot;<br>}</pre><p>The UI reads the stage name, and loads the corresponding view, prompting for a userid and password. It is technically possible to infer the view to load from the callbacks — e.g. NameCallback and PasswordCallback means that this is the login page. However the stage name is an unambiguous and consistent way to drive the UI logic, and provides a clean separation betwen the presentation layer and the backend logic.</p><p><strong>Note</strong>: when using stage names, some features of journey nodes must be avoided, as they conflict with the stage property of a Page Node. For example, in the Page Node itself, avoid the option “Submit Button Text”; in a Platform Password Node, avoid the “Confirm Password” option. These are display only options, which override the stage name with instructions to the in-built platform UI.</p><h3>Handling user facing messages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_UFLP_XuPZBxWy2Z4_23g.png" /></figure><p>User facing journey pages contain a mixture of static and dynamic content. The dynamic content is derived from information delivered to the UI by the backend journey. For example, when submitting an incorrect username and password, a journey may redisplay the username/password page with an error message. Or when sending a verification code, the journey displays a page with a masked phone number to send the message to.</p><p>There are various ways to include dynamic content in the callbacks sent from the journey backend. A simple method is to include a metadata callback with the message details: the JSON format of a metadata callback makes it straightforward for the UI app to parse.</p><p>For example, building on the userid/password stage from before, we can include any error codes in our login page by adding a State Metadata Node, which reads the <strong>errorMessage</strong> state variable and includes it in the callbacks sent to the UI.</p><p>When a password fails, we have a scripted decision node to set errorMessage as the corresponding error code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-jr6tC1cb3XI-WivoLOLQ.png" /></figure><p>When a user enters an incorrect userid or password, the journey loops back to the userid/password login page, and includes the error message taken from journey state:</p><pre>{<br>    &quot;authId&quot;: &quot;eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3aGl0ZWxpc3Qtc3RhdGUiOiI3NWQ5MzVjMy1hMDhhLTRkNTgtYTk3NS1jOWUyOTliNDgzNWUiLCJhdXRoSW5kZXhWYWx1ZSI6IkxvZ2luIiwib3RrIjoiZW1qM2g3NjhzdDJqbjJxdHAxamVxZGJpdWUiLCJhdXRoSW5kZXhUeXBlIjoic2VydmljZSIsIndoaXRlbGlzdC1sb2NrLWV4cGlyeSI6IjAiLCJyZWFsbSI6Ii9hbHBoYSIsInNlc3Npb25JZCI6IipBQUpUU1FBQ01ESUFCSFI1Y0dVQUNFcFhWRjlCVlZSSUFBSlRNUUFDTURFLipleUowZVhBaU9pSktWMVFpTENKamRIa2lPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LlpYbEtNR1ZZUVdsUGFVcExWakZSYVV4RFNteGliVTFwVDJsS1FrMVVTVFJSTUVwRVRGVm9WRTFxVlRKSmFYZHBXVmQ0YmtscWIybGFSMng1U1c0d0xpNUxkMWcwWjNGNGVTMTZNVU10Y3kxMGNVTkxjbFZCTGtZd1NsRndiVFF3WXpCaWVWSnNZMmhPYlRaSVp6UjVXWEUxTW10bk9UbFdaV1pHZEVaV1NtUnpUMlV3YWtoU1lWQjVZMjF0YWtsWVFYcEJTMVZFTFVkWmNDMW5lbkJMZWxoRFdIbHZYMVJsVlZGeFZVcEhOSGh1ZGtWUk1YWkVjMjE1UTJ4VE1uRlVlWEJHWlZwR1VXcFVlVXBuU21OMWFFMUpXRW8wZDBsWVRXVm9NRVF5VFhCVWJXRmllRXByTlRkc1NYcFZaRkZqTXpOdVJUVnpiblpUUVZGQk5tbG5XWGxaZWtwMVlqVkdPRlZaZURCelYybDFOMk5sTkd0dU5EaEJVamxDTTNaQ1pWVm1PR0ZvU1VGa1NETm5iV0ZoUWpCVVdIWkNNbGROUkVOeFVuWjBlRGRGVTBOa1ZtUTNTbWt6UXpWNFUyNUdOelIyVVU1dFpVaDFWRXc1WVhSamFWTnBZMGd4VEhGT2FHOHhUbGx0YldJMGVYaDZNbEZVU2paWVJGOU1ObTFIZFRWeE1uQXlNVk5LVVVGMmVHa3dYMWhEY3pSSk5tcE5SbWN3TkRSaE1tTXpPSEJQYVZZM1VWRmxVSFpWZVVwMWVHWlhiMk4xUkdwUloyTXhMWEJzTUVsWVdXZFFia3d6ZEVSSGNqRnBNMWczZGt0R1pqQnFNV0ZSVVZkMVNHTlRNR0pIYkVFdGJFd3RiMnBhYWpSNGVFOTRUVmh1TjJSRGIzWjFSRmxZTFhwQ2QySk9MVTlITW10RVFqZFhabmRvTkhVMVNtUmZaMWR2VFhvek0xOW1jR3BRTlU5VGFsVkVXbGRHY1djMVNsZDRVUzFVZWsxUFNITTFRa3B4Ym5CaWMxQXRia3hxUjJWTVpWRXRkSGRYWnpKU1Z5MDNhRmh3T1ZRNU5XOVpVMFJxV25wTldIVm9kVXRpVlVoTFdUTnNSVVZqWkRSME9GcFRURlpLTnpOSE4ydDJURFZtVmt4MVZrZHpOV0Z0VlRGcFdVaE1VSGRNUVZsWGVVZFZZV042ZWxwd2JHUnJZMUp5Vm5WdVRqWXdWbWt5UTBOT1dURnJOMWRoVTFoc2VqQklaMG80VjJ0U1dEUTVkVzVMWlV4MFpWRlNWVkJNTjNkNE1rVlJVRmt4VWxjMk0xcHRNbXhUWVdaRE4yVnJRVUpQZERVM1ZtWXlhVkZ6VG5wc1FqRlRNa3g0WVhoeVNrSXlTRWRuUm1OQmJXNDNTMmQ0ZFVac2JuWkhkRzVsUVZGMVgyTkZaMmRWTW1wbUxVdzVUMVJSYUZvdFUwNHlSRUZHTWkxYVMzTnpTbUpZWm5kSkxWQkNYMWRPZVRGWFVWcGFkekIzY1dsNVpWVmtVakZJY2xvME1VcDRhMDgxT0VSYVJtTjVZMk5zU0hsVWJsTk5NM1owWTNBdE9HaHVTbGQ0U1c5bGJYTlJRM2w1TW1Oalp6SXlaVkp4VFVkbGQzTktSVVJPVlhCRmFqQXplVjlzWVRaMFZWQlFUbUV0ZDNWR2JFMTViVFZPUWxSbFpsUk5iVGQ0Ym5wRlFrcDJhblJvYTNCV1FYVnlSVUV4UkZWU1RUaFpZV1JCTkdOeFZHNWZhMU15VVd0RU1VNU9RVU5qTkdveFJuUXpaWGxCTldsWU1rbHljekoyZUdkalgzbE1XalI0ZDFobVJYRTBjbGhUZWxKVVUwWkhURzFTWVhwWFJVTkZTRE5YTmtjdGJDMXZaamxJTVhWeWRrcEpOVGd0UVZGbVZtZE1ObkJUZEZNeExVRnBielZWZVRSU2JVUkJWMXA0UmpGME1VSjFkazVzU2xwa2RrbHZkazlVWm0xbU5sSm5VakZ1Y1ZsWFN6bDNkWEJmUVZKSU5GOUlTaTFwZW5Wek9GOHdiV1kwWlZjeGIwZHdhMVI1UlRGb1UyTjVZME0zUmw5WWQxaHZja1poYUZKRFFrVlJWa2RzZHpsd1dFdEhhR1pxWWtaVGJITnFkbFJRVXpsU2JEQmlOWFZGY2taZlJESk1WelJ5YUMwMFNYVjFNV0Z4U25CNE9UZExSbFJtWDNaTlZUZFBURXh2ZW5wbmFuZFNObHA1VG1KcVFrbGlRMk15TlVWdE1XZFlNMkY1Vm5JM00xZE9ZbkF3TjNnM1kxbHlPRlZJUWkxVWRXRkpUV0pvVTI5R1lqTkZSMlE0ZDNka1IydEZibkF0UW1wR05saHZSVVl3WmtGVUxXaEVRMWRzY25CNk4wMWZia2h5WXpkWFlrbEJiV3B4VjFWc1RVbEZSMDFsVkRKMFp6UlFOVUZvTlhWTlpVWnFhV0pKVGpKRWRWaGtjVmx4YlU4dE9XUmpNVTlyTmtjeVQwUTNkR3czUVZKclIyMHRTRGhoUzJ4NkxUSlRjV1JRTFVoUE56ZExhbEoxTWpaWlRuRkNTMXBGY0ZOS1gwdGpUbU0yU1ZvelZHUmpjRjlxZUVOV2RISnhSRmhoV2pKSVQwTjZRMHBhVGxSNU4wdFpTWFpSVEhOSGVTMU9hVmRpTnpOMlZWazBTMkpDWDNkRlEwaDZVemhvTlRJd1ZHcHlVMHBJVWs5d1VHZDViWHBRWDNrd2QzZEVNVU14TkVOQlJrNW5hRWhQYkdSWFVGVllRbWR3TUhkRmIwc3lUR3B2VVM1RVpWUlNabTR0U1RGUGJpMVBiSFJvVWxsSVIxcDMuWUstdnR1X3ZvLWQ0X3BhM2Fvb195LV9wUmE4VzBtVnc2cFZraC1uMXFLNCIsImV4cCI6MTc5MTMxNjA5OCwiaWF0IjoxNzkxMzE0Mjk4fQ.cZ8HT1tYoaH1CTvkjsmEr3Sx0uvtJrV-he79sR3tbTQ&quot;,<br>    &quot;callbacks&quot;: [<br>        {<br>            &quot;type&quot;: &quot;MetadataCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;data&quot;,<br>                    &quot;value&quot;: {<br>                        &quot;errorMessage&quot;: &quot;ERR0402&quot;<br>                    }<br>                }<br>            ],<br>            &quot;_id&quot;: 4<br>        },<br>        {<br>            &quot;type&quot;: &quot;NameCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;User Name&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken2&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 5<br>        },<br>        {<br>            &quot;type&quot;: &quot;PasswordCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;Password&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken3&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 6<br>        }<br>    ],<br>    &quot;stage&quot;: &quot;loginUserPass&quot;<br>}</pre><p>The UI maps the error code to a user facing message which can be displayed in the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-2unTLgEmavnET95plz-g.png" /></figure><p>This pattern can be used for any structured data to be delivered to the UI, such as user preferences, masked phone numbers and so on.</p><h3>Handling journey timeout</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hVsy_-DFOkUIF4IJnU4EoA.png" /></figure><p>Every journey has a maximum overall time to complete: the timeout period is <a href="https://docs.pingidentity.com/pingoneaic/am-authentication/realm-auth-config.html">configured at the realm level</a>, and may be overridden <a href="https://docs.pingidentity.com/auth-node-ref/latest/update-journey-timeout.html">within the journey</a> itself. When hitting the timeout period, the backend responds to the subsequent request with a 401 error, including a timeout message in the response body. The UI should handle this gracefully, informing the user that they have run out of time, and need to restart the journey.</p><p>There is one special timeout scenario which the UI should handle differently.</p><p>When a user logs out of an app, they are typically redirected back to the login page. At this point the UI starts a new instance of the journey, and the journey clock starts ticking. If the user leaves the browser tab and comes back to it later to log in, the journey may well have timed out. In this case, when the user submits their log in details, the backend responds with a 401 timeout. If this is passed through as a timeout message to the user, this can be confusing: from the end user point of view, they have only just started logging in.</p><p>In this scenario, rather than making the user start again, the UI should restart the journey and resubmit the initial login information supplied by the user. This means that the user experience is not impacted by the timeout. This only applies to the first step of the journey; if the user has gone beyond the first step, then we have truly timed out waiting for the user to respond.</p><p>The <a href="https://github.com/ForgeRock/platform-ui/tree/master/packages/platform-login">built-in platform UI</a> provides an example of how to handle this, calling the following function if the failure is a journey session timeout:</p><pre>retryWithNewAuthId(previousStep, stepParams) {<br>      this.getNewAuthId(stepParams)<br>        .then((authId) =&gt; {<br>          this.step = previousStep;<br>          if (has(this.step, &#39;payload&#39;)) {<br>            this.step.payload.authId = authId;<br>          }<br>          this.nextStep();<br>        });<br>    }</pre><h3>Handling successUrl and failureUrl at the end of a journey</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5BrLX9DVpIDYP2oYU6-RQ.png" /></figure><p>TL;DR — Pass through any <strong>goto</strong> and <strong>gotoOnFail </strong>URL parameters. At the end of a journey, check the response for a <strong>successUrl</strong> or <strong>failureUrl</strong> property and redirect the browser to the URL given.</p><p>When a login page is loaded, it is usually as part of a wider application flow. For example a user attempts to access an application, and is redirected to the login journey UI as part of an OpenID Connect (OIDC) flow. In this case, when the user successfully completes the login journey, they need to be redirected back to the authorisation service to continue login.</p><p>Another example is a registration journey, where the user is redirected back to a customer portal on completion.</p><p>The UI is informed of this requirement by attaching two specific URL parameters to the login redirect: <strong>goto </strong>and <strong>gotoOnFail</strong>. These parameters should be passed through to the Ping <strong>authenticate</strong> endpoint along with the rest of the inbound parameters, as we discussed in the previous section.</p><p>On <strong>successful</strong> completion of a journey, the response from the authentication service includes the property <strong>successUrl</strong> which informs the UI where to redirect the user to next:</p><pre>{<br> &quot;tokenId&quot;: &quot;JdrxLMs6z2sqvvitIltaK1qaIDE.*AAJTSQACMDIAAlNLABxXR2VHTDBNaUZpVWcveFhBTDBXN3pSYVpXR0U9AAR0eXBlAANDVFMAAlMxAAIwMQ..*&quot;,<br> &quot;successUrl&quot;: &quot;https://auth.acme.com/am/oauth2/realms/root/realms/bravo/authorize?client_id=acme-portal&amp;redirect_uri=https%3A%2F%2Fportal.acme.com&amp;response_type=code&amp;scope=openid%20profile&amp;state=NjIyMDAxNzMxNTkxMDIxMDgxMzIxMTg2OTE1NTQyNTA3ODEyMzE2MTE0MQ&amp;code_challenge=ErGuk0oiRuVIuuXYR4k2ODBo0w_TcEYE2ms3oRQE9Uw&amp;code_challenge_method=S256&quot;,<br> &quot;realm&quot;: &quot;/bravo&quot;<br>}</pre><p>On <strong>unsuccessful</strong> completion of the journey the response body includes the property <strong>failureUrl</strong> within the <strong>details</strong> property:</p><pre>{<br>    &quot;code&quot;: 401,<br>    &quot;reason&quot;: &quot;Unauthorized&quot;,<br>    &quot;message&quot;: &quot;Login failure&quot;,<br>    &quot;detail&quot;: {<br>        &quot;failureUrl&quot;: &quot;https://portal.acme.com/failedLogin&quot;<br>    }<br>}</pre><p>By default, these URLs are taken from the <strong>goto</strong> and <strong>gotoOnFail</strong> parameters passed to the UI. Note that they may be overridden by the journey logic.</p><p>It is the responsibility of the UI application to read the <strong>successUrl </strong>or <strong>failureUrl</strong> from the response and redirect the browser accordingly.</p><p><strong>Note</strong>: do not rely on the inbound <strong>goto</strong> and <strong>gotoOnFail </strong>parameters for redirecting the browser at the end of the journey: there is a potential for these to be exploited by an <a href="https://community.owasp.org/attacks/open_redirect">open redirect attack</a>. Use the <strong>successUrl </strong>or <strong>failureUrl</strong> in the backend response as the source of truth:</p><ol><li>All goto URLs are checked by the backend against the <a href="https://docs.pingidentity.com/pingoneaic/am-reference/services-configuration.html#realm-validation">URL validation service</a> to make sure they are authorised destination URLs. If the URL is not authorised, the backend returns the default destination URL <a href="https://docs.pingidentity.com/pingoneaic/am-authentication/realm-auth-config.html">configured in the platform</a>.</li><li>The backend may override the <strong>goto</strong>/<strong>gotoOnFail</strong> URLs — e.g. via the <a href="https://docs.pingidentity.com/auth-node-ref/latest/success-url.html">Success URL Node</a> and <a href="https://docs.pingidentity.com/auth-node-ref/latest/failure-url.html">Failure URL Node</a> respectively.</li></ol><p>By the way, you can also <a href="https://docs.pingidentity.com/pingoneaic/am-authentication/redirection-url-precedence.html#validate_a_goto_url">call the validation service directly</a> from the UI to check that a URL is valid, but for standard flows it is simpler to rely on <strong>successUrl/failureUrl.</strong></p><h3>Conclusion</h3><p>The Ping Orchestration SDK provides an efficient and consistent way to build your own user experience for any Ping journey, from registration to login and beyond. The SDK handles the complexity of reading and responding to callbacks, including complex interactions such as Device Profiling and WebAuthn flows. This article covers some of the last mile of UI implementation over and above the Ping SDK, to help deliver a robust and easily maintained UI to navigate Ping journeys and hand off to the overall application flow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f43b89b83ab0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a mobile launchpad for your web apps with PingOne Advanced Identity Cloud]]></title>
            <link>https://medium.com/@christian.brindley/create-a-mobile-launchpad-for-your-web-apps-with-pingone-advanced-identity-cloud-79a7faa095ed?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/79a7faa095ed</guid>
            <category><![CDATA[forgerock]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ping-identity]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[identity-management]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 15:35:48 GMT</pubDate>
            <atom:updated>2026-02-18T16:36:15.239Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNjHxN1PsSH_HCWnheIgBA.png" /></figure><h3>Introduction</h3><p>It can be hard to squeeze all of your online services into one mobile app. For any related services which are not built into the app itself, a common approach is to launch a WebView to load an external page. For example, a mobile banking app may launch a WebView to handle a loan application.</p><p>It is important how you treat people during this process. If your customer is already logged in via the app, they won’t want to log in again to apply for a loan.</p><p>In this article we’re going to show how to achieve single sign on between a mobile app and a WebView using the <a href="https://www.pingidentity.com/en/platform/pingone-advanced-identity-cloud.html">PingOne Advanced Identity Cloud</a> (AIC) platform. This provides the benefit of zero friction, backed by the inherently high assurance of native mobile.</p><p><strong>TL;DR </strong>— follow the steps in the <a href="https://github.com/christian-brindley/mobile-sso">sample github repo</a> to try it out for yourself.</p><h3>Sequence of events</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDV0cReruaNUycTe57jvDw.png" /></figure><p>The central plank of the SSO process is the <a href="https://docs.pingidentity.com/auth-node-ref/latest/backchannel-initialize.html#main_journey">Backchannel Authentication</a> feature of the PingOne AIC platform. This is a variation of the OTP based approach outlined in the <a href="https://docs.pingidentity.com/sdks/latest/sdks/use-cases/in-app-sso/index.html">Ping SDK documentation</a>. Using backchannel authentication removes the need for a custom OTP mechanism, and offers a way to enrich the SSO process with additional context.</p><p>The detailed sequence of events between the mobile app, the PingOne AIC platform and the launched WebView is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*z7COReKSFWqiHA55caDEGA.png" /></figure><p>This sequence consists of two main phases: <strong>initiation</strong> and <strong>launch</strong>. Let’s take a closer look at each of these phases.</p><h3>Initiation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erWALw3z9vJJWO2t6O7jMg.png" /></figure><p>The mobile app first makes a call to the PingOne AIC authentication service to request an SSO login URL for the web app. The request looks something this:</p><pre>curl --location --request POST &#39;https://openam-demo.forgeblocks.com/am/json/realms/root/realms/alpha/authenticate?authIndexType=service&amp;authIndexValue=Mobile%20SSO%20-%20Initialise<br>--header &#39;Accept-API-Version: protocol=1.0,resource=2.1&#39; \<br>--header &#39;Authorization: Bearer eyJ0eXAiOi...RElE3pxaEgTBg7A&#39; \<br>--header &#39;X-SSO-Location: https://openam-demo.forgeblocks.com/enduser/?realm=/alpha&#39; \<br>--header &#39;x-forgerock-transactionid: 68e0ab1e-6159-43e1-9dcc-22140c2d2531&#39;</pre><p>The request includes the following:</p><ul><li>An <strong>authorisation header</strong> with an access token to identify the logged in user: this access token is available in the app via the Ping SDK.</li><li>A <strong>custom header</strong> (X-SSO-Location) with the URL of the target app landing page</li></ul><p>The request is handled by a dedicated journey in PingOne AIC. This is configured as a “no session” journey, meaning that it does not create a new session for the mobile upon successful conclusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtuAHalmLVMe_STU6IBK2w.png" /><figcaption>Journey: Mobile SSO — Initialise</figcaption></figure><p>This initiation journey validates the access token, then initialises a separate backchannel journey to be passed to the WebView. This backchannel journey is primed with the user identity extracted from the access token, plus the target app to take the user to, along with any other contextual information which would be useful for the SSO process.</p><p>PingOne AIC responds back to the mobile app with the unique URL for the backchannel journey — e.g.</p><pre>{<br>    &quot;successUrl&quot;: &quot;https://openam-demo.forgeblocks.com:443/am/UI/Login?realm=%2Falpha&amp;authIndexType=transaction&amp;authIndexValue=9d7874a9-5007-49d5-b295-3576f5c82c1b&quot;,<br>    &quot;realm&quot;: &quot;/alpha&quot;<br>}</pre><p>The <strong>successUrl</strong> value is the unique URL to pass to the WebView to log the user in automatically. This is a transactional (i.e. one time) backchannel authentication URL, tied to this SSO request.</p><h3>Launch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3aMAEnUV2K77BXubXO1-A.png" /></figure><p>The mobile app then launches a WebView with the backchannel authentication URL. This loads the PingOne AIC login web app, which automatically runs the backchannel journey with no user interaction. The backchannel authentication process uses a handler journey configured in PingOne AIC, which can be as simple as this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGFYj5ecdgmxsOO0b8wfiQ.png" /><figcaption>Journey: Mobile SSO — Login</figcaption></figure><p>This validation node may do nothing, or may perform some additional (preferably non-interactive) verification, such as correlating the originating IP address with the initialisation request. You can introduce any number of additional validation steps, including calling out to a risk engine like <a href="https://www.pingidentity.com/en/product/pingone-protect.html">PingOne Protect</a>. The journey is configured as “transactional only” — i.e. it cannot be called outside the context of backchannel authentication or other transactional flow.</p><p>At the end of the journey, PingOne AIC creates a user session and sets the session cookie in the WebView. Along with the session cookie, PingOne AIC redirects the WebView to the target app landing page. Since the WebView has a session already, the user is automatically logged into the web application.</p><h3>Trying it out</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnrlCUunMp9n-seRyokb5g.png" /></figure><p>We can illustrate SSO using the following ingredients:</p><ul><li>A <strong>mobile app</strong> integrated with the Ping platform using the Ping mobile SDK. You can use the Ping SDK sample journey app to prove the concept.</li><li>A target <strong>web app</strong>, also integrated with the Ping platform. If you don’t have an app to hand, you can try it out with the end user profile management app which is built into the PingOne AIC platform.</li><li>A pair of <strong>journeys</strong> to handle the initialisation request and the backchannel authentication of the web app.</li></ul><p>For details, including sample journeys and code, check out the <a href="https://github.com/christian-brindley/mobile-sso">github repo</a> that goes along with this article.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*93AyZh1uS6X_Jp-R.jpg" /></figure><p>SSO between mobile and web channels offers a way for people to consume all of your online services as one seamless customer experience. The app becomes the anchor for identity across all channels, and opens up new ways of bringing customers directly into all of your applications and online services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79a7faa095ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Nodes in PingOne Advanced Identity Cloud — Staying in Control]]></title>
            <link>https://medium.com/@christian.brindley/custom-nodes-in-pingone-advanced-identity-cloud-staying-in-control-6aa0bae0b7f8?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa0bae0b7f8</guid>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[pingone-aic]]></category>
            <category><![CDATA[ping-identity]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 09:32:30 GMT</pubDate>
            <atom:updated>2025-11-04T09:32:30.511Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom Nodes in PingOne Advanced Identity Cloud — Staying in Control</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQCUN4lN2YJm2Ci3tHvn1A.png" /></figure><h3>Introduction</h3><p><a href="https://docs.pingidentity.com/pingoneaic/latest/getting-started/overview.html">PingOne Advanced Identity Cloud</a> (AIC) provides a comprehensive platform for building any kind of user journey: registration, login, credential recovery and any other use case you can think of. The platform provides a wide range of journey nodes which you can include as steps in your journey logic. If you have specific requirements which are not met by these out of the box nodes, you can implement your own logic using <a href="https://docs.pingidentity.com/pingoneaic/latest/journeys/node-designer.html">Custom Nodes</a>.</p><p>Custom Nodes are a step up from Scripted Decision Nodes, which also allow you to script your own journey logic. With Scripted Decision Nodes, you drop a node into a journey, and configure it with your own JavaScript based logic. You can’t feed any configuration into the script: any context specific information must be included in the script itself.</p><p>Custom Nodes on the other hand allow you to create a node which behaves just like an out of the box node. Custom Nodes appear alongside the standard nodes in the journey editor, and allow configuration options to be set in the usual way. This makes custom nodes more reusable than Scripted Decision Nodes, and provides a clean separation between node development and journey design.</p><p>By the way, <a href="https://docs.pingidentity.com/pingam/latest">PingAM</a> customers can also build Custom Nodes, as of PingAM Version 8.</p><h3>Staying in control</h3><p>For simple journey logic, you can easily build a Custom Node via the Ping administration UI. The node designer dialogues provide the tools to add a new node, configure its properties and add a script with the required logic.</p><p>However, once your node reaches a certain level of complexity, you starting hitting some engineering challenges:</p><ul><li><strong>Modular code</strong>. There is no way to import shared logic into your nodes — e.g. by calling out to shared library code.</li><li><strong>Version control</strong>. There is little concept of version control when developing custom nodes via the administration UI. You can tag your node with a version number, and maintain this as you develop, but there is no supporting framework beyond manually adjusting version tags.</li><li><strong>Code integrity</strong>. There is no inbuilt way to verify that the code is unaltered since it left your development pipeline.</li><li><strong>Developer experience</strong>. The Ping administration console provides a reasonable set of developer tools via the built-in script editor, but this will never be a match for dedicated third party IDE platforms such as VS Code, IntelliJ etc.</li></ul><p>Fortunately, there are ways to bring custom node development into line with standard engineering practices. In this article, we will explore how to develop Custom Nodes using <a href="https://www.typescriptlang.org/">TypeScript</a> and <a href="https://esbuild.github.io/">esbuild</a> for a more comfortable, consistent and productive developer experience.</p><h3>Let’s build a custom node</h3><p>We are now going to build a very simple journey node which displays a text message to the user.</p><p>To get started, clone <a href="https://github.com/christian-brindley/custom-nodes">this demo repo</a>, and install its dependencies:</p><pre>git clone https://github.com/christian-brindley/custom-nodes<br>cd custom-nodes<br>npm i</pre><p>Next, create the new node — we’ll give it the internal name “display-message”:</p><pre>git checkout -b node-display-message<br>npm run create display-message</pre><p>This creates a new package for our node: the file structure looks like this</p><pre>packages<br>└── display-message<br>    ├── node-config.json<br>    ├── package.json<br>    ├── src<br>    │   └── display-message.ts<br>    └── tsconfig.json</pre><ul><li>src/display-message.ts is the node script, coded using TypeScript</li><li>node-config.json is the node configuration</li><li>package.json contains the node version — starting at 1.0.0</li><li>tsconfig.json contains the required TypeScript configuration</li></ul><p>The display-message.tsscript initially looks like this:</p><pre>import { execNode } from &quot;@imports/common/node-base&quot;;<br><br>const nodeOutcomes = {<br>  COMPLETED: &quot;completed&quot;,<br>};<br><br>execNode(() =&gt; {<br>  // Node logic goes here<br>}, nodeOutcomes.COMPLETED);</pre><p>This provides the bare bones of a Custom Node:</p><ul><li>nodeOutcomes is the declaration of any outcomes which this node will produce</li><li>execNode gives us a wrapper for the node which handles exceptions gracefully, and anything else we want to do for all nodes</li></ul><p>The starter script is for a single outcome node — i.e. it will always complete with the outcome completed. Nodes with multiple outcomes should include an error outcome and pass this in as the final parameter for execNode().</p><h3>Adding the node properties and other configuration</h3><p>Update node-config.json with some basic configuration, by modifying the following sections:</p><ul><li>displayName - The name shown in the journey designer</li><li>description - A description for the node</li><li>properties - The node&#39;s configurable properties</li></ul><p>For the propertiessection, we are going to configure two configuration options:</p><ul><li>message— The message text to display</li><li>level— The message level to use — INFO, WARNING or ERROR</li></ul><p>We end up with a node-config.json like this:</p><pre>{<br>  &quot;_id&quot;: &quot;displaymessage-1&quot;,<br>  &quot;displayName&quot;: &quot;Display Message&quot;,<br>  &quot;description&quot;: &quot;Display a message in a form field&quot;,<br>  &quot;errorOutcome&quot;: false,<br>  &quot;inputs&quot;: [],<br>  &quot;outcomes&quot;: [],<br>  &quot;outputs&quot;: [],<br>  &quot;properties&quot;: {<br>    &quot;message&quot;: {<br>      &quot;description&quot;: &quot;Message to display&quot;,<br>      &quot;multivalued&quot;: false,<br>      &quot;required&quot;: true,<br>      &quot;title&quot;: &quot;Message&quot;,<br>      &quot;type&quot;: &quot;String&quot;<br>    },<br>    &quot;level&quot;: {<br>      &quot;title&quot;: &quot;Level&quot;,<br>      &quot;description&quot;: &quot;Message level&quot;,<br>      &quot;type&quot;: &quot;STRING&quot;,<br>      &quot;required&quot;: true,<br>      &quot;options&quot;: {<br>        &quot;INFO&quot;: &quot;INFO&quot;,<br>        &quot;WARNING&quot;: &quot;WARNING&quot;,<br>        &quot;ERROR&quot;: &quot;ERROR&quot;<br>      },<br>      &quot;multivalued&quot;: false,<br>      &quot;defaultValue&quot;: &quot;INFO&quot;<br>    }<br>  },<br>  &quot;serviceName&quot;: &quot;displaymessage&quot;,<br>  &quot;tags&quot;: []<br>}</pre><p>Don’t worry about the outcomes property: the build will automatically set this from the nodeOutcomes declaration in the script. The tags property will also be updated during the build, adding a tag with the version number from package.json.</p><h3>Adding the node logic</h3><p>We are now going to update display-message.ts with the script logic to display a message at the required level:</p><pre>import { execNode } from &quot;@imports/common/node-base&quot;;<br>import { MESSAGE_LEVEL } from &quot;@imports/common/constants&quot;;<br><br>const nodeOutcomes = {<br>  COMPLETED: &quot;completed&quot;,<br>};<br><br>execNode(() =&gt; {<br>  if (callbacks.isEmpty()) {<br>    callbacksBuilder.textOutputCallback(<br>      MESSAGE_LEVEL[properties.level as keyof typeof MESSAGE_LEVEL],<br>      properties.message<br>    );<br>    return;<br>  }<br>  action.goTo(nodeOutcomes.COMPLETED);<br>}, nodeOutcomes.COMPLETED);</pre><h3>Build and deploy the node</h3><p>We are now ready to build and deploy the node. The build process will convert the TypeScript source into common JavaScript, expanding any imports to provide a standalone node script which the Ping environment can consume.</p><p>There are two ways you can deploy the node into your Ping environment:</p><ul><li>Build a JSON import file and import manually via the Ping admin console</li></ul><p>or</p><ul><li>Push the node directly into the Ping environment via REST</li></ul><h4>Importing manually</h4><p>To import the node manually via the Ping admin console, first build the import JSON as follows:</p><pre>npm run build display-message</pre><p>This creates the import file packages/display-message/dist/display-message.1.0.0.json which you can import via the admin console.</p><h4>Pushing directly via REST (PingOne AIC)</h4><p>First, configure your environment details. Copy the sample .env file</p><pre>cp .env.sample .env</pre><p>Next, edit the .env file with your Ping environment URL and service account credentials - i.e.</p><ul><li><strong>TENANT_BASE_URL</strong></li><li><strong>SERVICE_ACCOUNT_ID</strong></li><li><strong>SERVICE_ACCOUNT_CLIENT_ID</strong></li><li><strong>SERVICE_ACCOUNT_SCOPE</strong></li><li><strong>SERVICE_ACCOUNT_KEY</strong></li></ul><p>The sample .env file includes notes on each of these properties.</p><p>Now you are ready to deploy the node into your PingOne AIC environment</p><pre>npm run deploy display-message</pre><p>This will build the JSON import file, then push the node config via REST. The node may be modified locally and redeployed to update the installed version.</p><h3>Use the node in your journeys</h3><p>Once you have deployed the node, it is available in the journey editor alongside the out of the box nodes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ldN-E2kvYOdHKNZ7-XpV3Q.png" /></figure><h3>Signed nodes</h3><p>If the SIGN property in the .env file is set to true, the property signature is added to the metadata in the JSON import file. The value of this property is an RFC 7797 detached JWT — e.g.</p><pre>&quot;signature&quot;: &quot;eyJraWQiOiJteS1wdWJsaXNoZXIta2V5LTEiLCJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..QnF9fkYn_osm_5d3a5hHqR-OIiENgQMbHbgkQO7sTfcgv1PRRykVXbN6Lv7lCOTWqXc7v7Ia0Z1nrfMNXB2fc0AZ2IUHexV09e8g_mipcktiWvsCUYC4Fujs5Qzz-vue-Fn0pS9sBz1djx_Vlyn0xcMtwS_5JNrHhqjaj_sOWcWcYnRca1SDS-Q_Bh-uXlzeAHj1cQSJItUVDIIkxYHVc5T0ynLGVlK_4LEOpxz1VR8ei3Pae6oJuMa-EZuNOdfhkNG4pdgl6xgDzH7MM_7PModjFlRfKOcAibBQQ7UpotNEQtdP4STPVVJbUZXYgnNZ6ayslm5e2vGek9oksu0WyNTdqWQpMaKl0SIRNX0yY9i-rJf_N5AvVJcFX3HlZG1dr0TzokzjLenzAvQWYlKGT7UZZ9yYXfU_X-qvOADJyUMd9g1CtDMd_yFf1wCNkwOykCgl9gJQrlcG_l9XD2zoiTn_L3MSuHl-MZpUdwYrNxLlbVsiNshLNGAm9CL-S3UgYzinv7u41hQ01dwl2kIwWKkUyN06gZNSGY9Y2oii3sZcKFVHa5_BHK1ayO9x6YfAkvlDvIca_ARVHu3P3jA_-Rw1wrjyR8r1N7Mgq7MiJZ6M-k6ACOSGMxHQQ2upZifEHrRBLC4R2s_Gm__IQtX_IAtriJ11cahdviyLtURXikg</pre><p>The signature is applied to the node object within the JSON import — i.e. the object under nodeTypes.displaymessage-1 in the example node.</p><pre>{<br>    ...<br>    &quot;nodeTypes&quot;: {<br>    &quot;displaymessage-1&quot;: {<br>      &quot;_id&quot;: &quot;displaymessage-1&quot;,<br>      ...<br>    }<br>  }</pre><p>To perform signatures, the SIGNER_KEY property in the .env file must be set to a private key JWK.</p><p>The Ping platform does not verify this signature; this would need to be implemented as part of a configuration pipeline.</p><h3>Conclusion</h3><p>For simple Custom Nodes, the Ping administration UI is sufficient for development purposes. However once you reach a certain level of complexity, it helps to be able to build Custom Nodes in an environment more suited to application development, with strict version control, modular code and modern development tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa0bae0b7f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing journeys in PingOne Advanced Identity Cloud]]></title>
            <link>https://medium.com/@christian.brindley/testing-journeys-in-pingone-advanced-identity-cloud-7e7da92c1aaf?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e7da92c1aaf</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[forgerock-identity-cloud]]></category>
            <category><![CDATA[ping-identity]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 18:08:38 GMT</pubDate>
            <atom:updated>2024-10-28T18:08:38.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0Ew7UZlzduIo5UKi" /></figure><h3>Introduction</h3><p><a href="https://www.pingidentity.com/en/platform/pingone-advanced-identity-cloud.html">PingOne Advanced Identity Cloud (AIC)</a> allows you to create end user journeys for any use case your organisation requires — from registration, to login, to self service and beyond.</p><p>As with all configuration, journeys should be treated as code — developed and maintained within a version control framework and automatically tested as part of a continuous delivery pipeline.</p><p>So how do you automate testing of user journeys? One approach is to test your login UI via a web application testing framework such as <a href="https://playwright.dev/">Playwright</a> or <a href="https://www.cypress.io/">Cypress</a>. This is a good way of testing both the UI and the backend journey logic.</p><p>An alternative (or complimentary) approach is to test the underlying service APIs directly, using a REST based testing framework such as <a href="https://www.postman.com/">Postman</a> or <a href="https://insomnia.rest/">Insomnia</a>: in this case, your tests are verifying the backend journey logic in isolation from the journey UI.</p><p>In order to understand how to test AIC journeys via REST, you need to understand how journeys work under the covers.</p><h3>Walking through a journey</h3><p>AIC journeys consist of a number of steps — or nodes — each of which is either a <strong>callback</strong> requesting information from the user, or backend logic for transforming data, calling external systems, performing identity management functions and so on.</p><p>This is the backend view of a typical login journey:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHSsMkU8jN7vwQftR4GrCg.png" /><figcaption>Login Journey</figcaption></figure><p>When the login UI starts, it sends a POST request with no payload to the AIC REST endpoint to start the journey :</p><pre>POST https://openam-demo.forgeblocks.com/am/json/realms/root/realms/alpha/authenticate?authIndexType=service&amp;authIndexValue=Login%20Demo</pre><p>The URL includes a parameter indicating the name of the journey to invoke.</p><p>The response to the REST request contains instructions on what to do next — e.g. for the example above, the first response will contain a pair of callbacks requesting the userid and password:</p><pre>{<br>    &quot;authId&quot;: &quot;eyJ0eXAiOiJK...TO278MBuow&quot;,<br>    &quot;callbacks&quot;: [<br>        {<br>            &quot;type&quot;: &quot;NameCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;User Name&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken1&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 0<br>        },<br>        { <br>            &quot;type&quot;: &quot;PasswordCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;Password&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken2&quot;,<br>                    &quot;value&quot;: &quot;&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 1<br>        }<br>    ],<br>    &quot;stage&quot;: &quot;collectUserPass&quot;,<br>    &quot;header&quot;: &quot;Welcome&quot;,<br>    &quot;description&quot;: &quot;Please enter your userid and password.&quot;<br>}</pre><p>The UI displays these callbacks as input fields for the user to complete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HjhBihC8wvLlOeInZGd3OQ.png" /></figure><p>When the user enters their username and password, the UI app sends a POST request back to the AIC REST API, replaying the authId token from the previous response, together with the completed callbacks e.g.</p><pre>POST https://openam-demo.forgeblocks.com/am/json/realms/root/realms/alpha/authenticate<br>{<br>    &quot;authId&quot;: &quot;eyJ0eXAi...WTS9iOEpn0hcWENrtctw6mI&quot;,<br>    &quot;callbacks&quot;: [<br>        {<br>            &quot;type&quot;: &quot;NameCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;User Name&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken1&quot;,<br>                    &quot;value&quot;: &quot;jane.doe&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 0<br>        },<br>        {<br>            &quot;type&quot;: &quot;PasswordCallback&quot;,<br>            &quot;output&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;prompt&quot;,<br>                    &quot;value&quot;: &quot;Password&quot;<br>                }<br>            ],<br>            &quot;input&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;IDToken2&quot;,<br>                    &quot;value&quot;: &quot;fsdfjKK890%$&quot;<br>                }<br>            ],<br>            &quot;_id&quot;: 1<br>        }<br>    ]<br>}&#39;</pre><p>Note that you don’t need to specify the journey name in subsequent URLs: the authId token provides the running journey state. This applies to any other parameters you attach to the initial call to the authenticate endpoint, such as goto URLs etc.</p><p>In response to the REST call with the completed callbacks, the AIC platform processes the input data, and responds with the next set of callbacks, and so on.</p><p>When the journey completes successfully, the AIC API responds not with a request for callbacks, but with a session token provided in the response body, and as a Set-Cookie header — e.g.</p><pre>{<br>    &quot;tokenId&quot;: &quot;yEeAArQdRSYhgaYZ3oIER-6LAtQ.*AAJTSQACMDIAAlNLABxFbHJhTFBoWllGck4wQWFwQzhNaWpTZkdlYnc9AAR0eXBlAANDVFMAAlMxAAIwMQ..*&quot;,<br>    &quot;successUrl&quot;: &quot;/enduser/?realm=/alpha&quot;,<br>    &quot;realm&quot;: &quot;/alpha&quot;<br>}</pre><p><strong>Note</strong>: the tokenId property may be empty if AIC is configured to return the session token as a cookie only.</p><h3>Testing a journey</h3><p>When testing a journey via REST, you are emulating the behaviour of the UI, issuing successive POST requests to walk through the callbacks until the conclusion of the journey. While testing, you are checking that:</p><ul><li>you receive the callback requests and stage name you expect at each step in the journey</li><li>the journey concludes successfully (or unsuccessfully) as expected</li></ul><p>As an example, if using Postman to test your journey, each request has a post request script which tests for the expected callbacks, and records the authId for the next request — e.g.</p><pre>pm.test(&quot;200 response&quot;, function () {<br>    pm.response.to.have.status(200);<br>});<br>const jsonData = pm.response.json();<br>pm.test(&quot;authId token in response&quot;, function () {<br>    pm.expect(jsonData.authId).to.be.a(&quot;string&quot;);<br>    pm.collectionVariables.set(&quot;authId&quot;, jsonData.authId);<br>});<br>pm.test(&quot;Check username and password prompt&quot;, function () {<br>    pm.expect(jsonData.callbacks.length).to.eql(2);<br>    pm.expect(jsonData.callbacks[0].type).to.eql(&quot;NameCallback&quot;); <br>    pm.expect(jsonData.callbacks[1].type).to.eql(&quot;PasswordCallback&quot;); <br>});<br>pm.test(&quot;Check stage is collectUserPass&quot;, function () {<br>    pm.expect(jsonData.stage).to.eql(&quot;collectUserPass&quot;);<br>});</pre><p>The last test will look a little different, because you are not expecting any more callbacks; you are instead expecting a session token:</p><pre>pm.test(&quot;200 response&quot;, function () {<br>    pm.response.to.have.status(200);<br>});<br>const jsonData = pm.response.json();<br>pm.test(&quot;tokenId in response&quot;, function () {<br>    pm.expect(jsonData.tokenId).to.be.a(&quot;string&quot;);<br>});<br>const cookieName = await utils.getSessionCookieName(pm);<br>pm.test(&quot;Session cookie set&quot;, function () {<br>    pm.expect(pm.cookies.has(cookieName)).to.be.true;<br>});</pre><p><strong>Note</strong>: When testing for the expected stage value, be aware that under certain circumstances, the stage name is overridden by page configuration. This only applies to journeys designed for use by the default journey UI built into the AIC platform — also known as the <a href="https://docs.pingidentity.com/pingoneaic/latest/end-user/identity-cloud-hosted-pages.html">Hosted Pages</a>. When developing your own journey UI, you can use stage names to unambiguously identity the page to display. Either way, you will have a predictable stage name which you can test against.</p><h3>Types of testing</h3><p>You should implement at least two types of testing — functional tests and performance tests.</p><p><strong>Functional tests</strong> check the logic of your journey, and should test every scenario. Tests should include both happy paths — e.g. successful login — and unhappy paths — password failure, unrecognised user, account lockout and so on. These tests should be run in your Development environment before promoting journeys to higher environments.</p><p>You may also opt to run functional tests in your Sandbox environment, if you have one. Sandbox environments are included in the <a href="https://docs.pingidentity.com/pingoneaic/latest/release-notes/rapid-channel-changelog.html">AIC Rapid Release channel</a>, meaning that service updates are applied to Sandbox ahead of the Regular Release channel which feeds your main AIC tenant environments. This gives you assurance that your journeys will continue to behave as expected as service updates are introduced. Note that service updates are introduced as non-breaking changes, with backwards compatibility in mind, as per any typical SaaS platform. You would therefore not normally expect to find issues through continuous testing in the Sandbox environment; this is more a way of providing additional assurance to your wider organisation, if this is a business requirement for consuming Software as a Service.</p><p><strong>Performance tests</strong> are carried out to ensure that your journeys will perform acceptably under production level load. The goal is not to load the platform to breaking point; you are ensuring that under realistic peak production load, response times fall within the range required by the business. These tests are run in your Staging or UAT environment, which are provisioned with the same architecture and capacity as the production environment.</p><h3>Debugging</h3><p>If your tests fail, you can check the <a href="https://backstage.forgerock.com/docs/idcloud/latest/tenants/audit-debug-logs.html">backend AIC logs</a> to see what went wrong.</p><p>AIC logs are extremely chatty, particularly in the development environment, so it helps if you can isolate the log messages that are relevant to your test. This is achieved through the use of transaction IDs.</p><p>Each REST request in your journey test should include an X-ForgeRock-TransactionId header with a fixed unique value, such as a random UUID. You can then pull log messages with just that transaction ID.</p><p>You can refine this by appending a sequential counter to the transaction id for each request: you then pull log messages with the base value to get log messages for the entire journey, or include the counter to get log messages for a specific stage.</p><h3>Sample tests</h3><p>For a more detailed example of how to test a journey, refer to <a href="https://github.com/christian-brindley/journey-testing">this sample journey and associated Postman collection</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nS6XTgLJOC-F0XZqtuI8rg.png" /></figure><p>The sample collection has the following folder structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdYyR6Nx6vdIagjcXHD9Xw.png" /></figure><ul><li><strong><em>Initialisation</em></strong> contains a request to create a test userid.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8NAAmOQFEsgl8YyE2bk9A.png" /><figcaption>Create test user</figcaption></figure><ul><li><strong><em>Login Journey — Unregistered Device</em></strong> is the set of requests to run through userid/password validation, MFA via email, and device registration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGb3MXTazd4jvZ_iMPR-8A.png" /><figcaption>First time login</figcaption></figure><ul><li><strong><em>Login Journey — Registered Device</em></strong> can be run immediately afterwards to check that device registration has worked</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-jVhE97Jr53SSFouNoBc8w.png" /><figcaption>Login with registered device</figcaption></figure><ul><li><strong><em>Cleanup</em></strong> removes the test user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iXJzGx3T6PdDuF27RYYQEQ.png" /><figcaption>Delete test user</figcaption></figure><ul><li><strong><em>Logs</em></strong> can be used to pull logs for the latest transaction ID used by journey tests</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbTLZejRTf-RrsvbFaTenQ.png" /><figcaption>Journey logs</figcaption></figure><p>Refer to the repository README for more details on how to set up and use the collection.</p><h3>Conclusion</h3><p>Automated testing is an essential component of any AIC deployment. Every journey should have an associated test which can be used standalone or as part of a CI/CD pipeline to ensure business continuity as your configuration evolves. REST based journey tests are a simple and effective way of testing journey logic in isolation from the UI or any other relying applications. Journey tests also form the foundation for further testing, such as OAuth2/OIDC flows, delegated administration features and any other functional tests which rely on a user session.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e7da92c1aaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PingOne Advanced Identity Cloud — Making announcements at login (how-to)]]></title>
            <link>https://medium.com/@christian.brindley/pingone-advanced-identity-cloud-making-announcements-at-login-how-to-848b3b948fd1?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/848b3b948fd1</guid>
            <category><![CDATA[ami]]></category>
            <category><![CDATA[pingone]]></category>
            <category><![CDATA[aic]]></category>
            <category><![CDATA[forgerock-identity-cloud]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Fri, 27 Sep 2024 07:22:27 GMT</pubDate>
            <atom:updated>2024-09-27T11:56:39.968Z</atom:updated>
            <content:encoded><![CDATA[<h3>PingOne Advanced Identity Cloud — Making announcements at login (how-to)</h3><h3>Introduction</h3><p><a href="https://www.pingidentity.com/en/platform/pingone-advanced-identity-cloud.html">PingOne Advanced Identity Cloud</a> (or PingOne AIC for short) allows you to tailor your end user login experience via its extensive theming options.</p><p>In a <a href="https://medium.com/@christian.brindley/pingone-advanced-identity-cloud-making-announcements-at-login-intro-012e026bc26a">previous article</a>, we described at a high level how it is possible to use journey themes with <a href="https://backstage.forgerock.com/docs/idcloud/latest/end-user/customize-login-enduser-pages.html#use-script-tags-in-identity-cloud-end-user-and-login-uis">script tags</a> to do a number of useful things, such as integrating with cookie preferences or analytics platforms, or displaying a banner with system messages at login:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hfeJKvvI0nKhN6VOxVBU8A.png" /></figure><p>In this article, we are going to provide the technical details on how to implement a dynamic message banner, via configuration alone.</p><h3>The building blocks</h3><p>The following building blocks are required for the page banner:</p><ul><li>A <a href="https://backstage.forgerock.com/docs/idcloud/latest/idm-objects/appendix-managed-objects.html"><strong>managed object</strong></a> to store announcements</li><li>A <a href="https://backstage.forgerock.com/docs/idcloud/latest/developer-docs/scripting-custom-endpoints.html"><strong>custom endpoint</strong></a>, which provides an API to publish these announcements</li><li>A hosted pages <a href="https://backstage.forgerock.com/docs/idcloud/latest/end-user/customize-login-enduser-pages.html#add-a-custom-theme"><strong>theme</strong></a> which includes a JavaScript snippet to show the banner</li></ul><p>To display the banner, the JavaScript snippet sets dynamic content in the hosted page content. This is something we would avoid in backend journey logic: the underlying structure of the hosted pages will change over time, so we don’t want to rely on service owned elements of the UI. In this case however, we are staying within the customer owned elements of the hosted UI— namely the theme header and script tag configuration.</p><h3>Configure the announcement object</h3><p>First create a new object in PingOne AIC to store announcements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NuJ1TxRgm-8HE5mmYD6sA.png" /><figcaption>communictyAnnouncement object</figcaption></figure><p>This has the following properties:</p><p><strong>_id </strong>is the unique identifier for the announcement. We are using this for the audience — e.g. “customerLogin”. We can add multiple types of announcement, for other use cases besides login.</p><p><strong>audience</strong> is a virtual property which just returns the value of <strong>_id</strong>. This is for convenience in the admin UI.</p><p><strong>description</strong> allows a freeform description for this announcement — e.g. “Displayed to customers at login”.</p><p><strong>announcements</strong> is an array of announcements. A maximum of one announcement can be active at any one time. We have implemented this as a set rather than a single announcement so that you can swap between messages, and keep stock messages for later. If you think this is overkill, you could just have a single message with an on/off toggle.</p><p><strong>activeAnnouncement</strong> is a virtual property which returns the active announcement. This is for convenience when implementing the API later on.</p><p>The <strong>announcements</strong> property looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkV29lsYcdbvRWjB2YPjFQ.png" /></figure><p>For JSON fans, here is the raw managed object config:</p><pre>{<br>  &quot;name&quot;: &quot;communityAnnouncement&quot;,<br>  &quot;onUpdate&quot;: {<br>    &quot;globals&quot;: {},<br>    &quot;type&quot;: &quot;text/javascript&quot;,<br>    &quot;source&quot;: &quot;if (\n  newObject.announcements.filter((anncouncement) =&gt; anncouncement.enabled)\n    .length &gt; 1\n) {\n  throw {\n    code: 400,\n    message: \&quot;Only one announcement can be enabled at one time\&quot;,\n  };\n}\n&quot;<br>  },<br>  &quot;schema&quot;: {<br>    &quot;$schema&quot;: &quot;http://forgerock.org/json-schema#&quot;,<br>    &quot;icon&quot;: &quot;fa-comment-o&quot;,<br>    &quot;mat-icon&quot;: &quot;&quot;,<br>    &quot;order&quot;: [<br>      &quot;_id&quot;,<br>      &quot;audience&quot;,<br>      &quot;description&quot;,<br>      &quot;announcements&quot;,<br>      &quot;activeAnnouncement&quot;<br>    ],<br>    &quot;properties&quot;: {<br>      &quot;_id&quot;: {<br>        &quot;description&quot;: null,<br>        &quot;format&quot;: null,<br>        &quot;isVirtual&quot;: false,<br>        &quot;searchable&quot;: true,<br>        &quot;title&quot;: &quot;Audience ID&quot;,<br>        &quot;type&quot;: &quot;string&quot;,<br>        &quot;userEditable&quot;: true,<br>        &quot;viewable&quot;: true<br>      },<br>      &quot;activeAnnouncement&quot;: {<br>        &quot;description&quot;: null,<br>        &quot;isVirtual&quot;: true,<br>        &quot;onRetrieve&quot;: {<br>          &quot;globals&quot;: {},<br>          &quot;type&quot;: &quot;text/javascript&quot;,<br>          &quot;source&quot;: &quot;var activeAnnouncement = {};\n\nobject.announcements.forEach((announcement) =&gt; {\n  if (announcement.enabled) {\n    activeAnnouncement = announcement;\n  }\n});\n\nactiveAnnouncement;&quot;<br>        },<br>        &quot;order&quot;: [],<br>        &quot;properties&quot;: {},<br>        &quot;required&quot;: [],<br>        &quot;returnByDefault&quot;: false,<br>        &quot;scope&quot;: &quot;private&quot;,<br>        &quot;searchable&quot;: false,<br>        &quot;title&quot;: &quot;Active Announcement&quot;,<br>        &quot;type&quot;: &quot;object&quot;,<br>        &quot;userEditable&quot;: true,<br>        &quot;viewable&quot;: false<br>      },<br>      &quot;announcements&quot;: {<br>        &quot;description&quot;: null,<br>        &quot;isVirtual&quot;: false,<br>        &quot;items&quot;: {<br>          &quot;order&quot;: [<br>            &quot;level&quot;,<br>            &quot;content&quot;,<br>            &quot;enabled&quot;<br>          ],<br>          &quot;properties&quot;: {<br>            &quot;content&quot;: {<br>              &quot;searchable&quot;: false,<br>              &quot;title&quot;: &quot;Content&quot;,<br>              &quot;type&quot;: &quot;string&quot;,<br>              &quot;userEditable&quot;: true,<br>              &quot;viewable&quot;: true<br>            },<br>            &quot;enabled&quot;: {<br>              &quot;searchable&quot;: false,<br>              &quot;title&quot;: &quot;Enabled&quot;,<br>              &quot;type&quot;: &quot;boolean&quot;,<br>              &quot;userEditable&quot;: true,<br>              &quot;viewable&quot;: true<br>            },<br>            &quot;level&quot;: {<br>              &quot;searchable&quot;: false,<br>              &quot;title&quot;: &quot;Level&quot;,<br>              &quot;type&quot;: &quot;string&quot;,<br>              &quot;userEditable&quot;: true,<br>              &quot;viewable&quot;: true<br>            }<br>          },<br>          &quot;required&quot;: [],<br>          &quot;type&quot;: &quot;object&quot;<br>        },<br>        &quot;searchable&quot;: false,<br>        &quot;title&quot;: &quot;Announcements&quot;,<br>        &quot;type&quot;: &quot;array&quot;,<br>        &quot;userEditable&quot;: true,<br>        &quot;viewable&quot;: true<br>      },<br>      &quot;audience&quot;: {<br>        &quot;description&quot;: null,<br>        &quot;format&quot;: null,<br>        &quot;isVirtual&quot;: true,<br>        &quot;onRetrieve&quot;: {<br>          &quot;globals&quot;: {},<br>          &quot;type&quot;: &quot;text/javascript&quot;,<br>          &quot;source&quot;: &quot;object._id&quot;<br>        },<br>        &quot;returnByDefault&quot;: true,<br>        &quot;searchable&quot;: false,<br>        &quot;title&quot;: &quot;Audience&quot;,<br>        &quot;type&quot;: &quot;string&quot;,<br>        &quot;userEditable&quot;: true,<br>        &quot;viewable&quot;: true<br>      },<br>      &quot;description&quot;: {<br>        &quot;description&quot;: &quot;Description&quot;,<br>        &quot;format&quot;: null,<br>        &quot;isVirtual&quot;: false,<br>        &quot;searchable&quot;: false,<br>        &quot;title&quot;: &quot;Description&quot;,<br>        &quot;type&quot;: &quot;string&quot;,<br>        &quot;userEditable&quot;: true,<br>        &quot;viewable&quot;: true<br>      }<br>    },<br>    &quot;required&quot;: [<br>      &quot;_id&quot;<br>    ],<br>    &quot;title&quot;: &quot;Community Announcement&quot;,<br>    &quot;type&quot;: &quot;object&quot;<br>  }<br>}</pre><h3>Create an announcement set</h3><p>Now that the <strong>communityAnnouncement</strong> object has been configured, create an announcement set— e.g.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dPsQ7X-EaTVUL-6NyI6TQ.png" /></figure><p>This announcement set is intended for the login page (audience “customerLogin”). You’ll see how this works later. If you enable none of the announcements in the set, no banner will be shown. In the example above, the planned maintenance warning is enabled.</p><h3>Custom endpoint</h3><p>Next, define a new endpoint which will provide an API to fetch announcements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ODvpQ9xF2Xm__AybpCHWg.png" /><figcaption>Announcement endpoint</figcaption></figure><p>The script for this endpoint is as follows:</p><pre>(function () {<br>  if (request.method === &quot;read&quot;) {<br>    const audience = request.resourcePath;<br>    if (!audience) {<br>      throw {<br>        code: 400,<br>        message: &quot;No audience in request path&quot;,<br>      };<br>    }<br><br>    const announcement = openidm.read(<br>      `managed/${endpointConfig.announcementObjectName}/${audience}`,<br>      null,<br>      [endpointConfig.announcementProperty]<br>    );<br><br>    if (!announcement) {<br>      throw {<br>        code: 404,<br>        message: `No announcement for audience ${audience}`,<br>      };<br>    }<br><br>    return announcement.activeAnnouncement;<br>  }<br>  throw { code: 405, message: &quot;Unsupported method:&quot; + request.method };<br>})();</pre><p>This expects a GET request with the required audience, like this:</p><pre>https://openam-demo.forgeblocks.io/openidm/endpoint/audience/customerLogin</pre><p>The endpoint will return the active announcement for this audience, like this:</p><pre>{<br>    &quot;_id&quot;: &quot;customerLogin&quot;,<br>    &quot;level&quot;: &quot;WARN&quot;,<br>    &quot;content&quot;: &quot;Planned maintenance: 24 Sep 2024, 03:00 to 04:00&quot;,<br>    &quot;enabled&quot;: true<br>}</pre><p>In order to separate configuration from script, set the globals property as part of the endpoint configuration. The full raw JSON for the endpoint, with the squashed script, looks like this:</p><pre>{<br>  &quot;_id&quot;: &quot;endpoint/announcement&quot;,<br>  &quot;description&quot;: &quot;Endpoint for retrieving system messages to show to end users&quot;,<br>  &quot;globals&quot;: {<br>    &quot;endpointConfig&quot;: {<br>      &quot;announcementObjectName&quot;: &quot;communityAnnouncement&quot;,<br>      &quot;announcementProperty&quot;: &quot;activeAnnouncement&quot;<br>    }<br>  },<br>  &quot;type&quot;: &quot;text/javascript&quot;,<br>  &quot;source&quot;: &quot;(function () {\n  if (request.method === \&quot;read\&quot;) {\n    const audience = request.resourcePath;\n    if (!audience) {\n      throw {\n        code: 400,\n        message: \&quot;No audience in request path\&quot;,\n      };\n    }\n\n    const announcement = openidm.read(\n      `managed/${endpointConfig.announcementObjectName}/${audience}`,\n      null,\n      [endpointConfig.announcementProperty]\n    );\n\n    if (!announcement) {\n      throw {\n        code: 404,\n        message: `No announcement for audience ${audience}`,\n      };\n    }\n\n    return announcement.activeAnnouncement;\n  }\n  throw { code: 405, message: \&quot;Unsupported method:\&quot; + request.method };\n})();\n&quot;<br>}</pre><p>If you are using the admin UI (rather than REST) to create the endpoint, this makes it difficult to set the globals property as above. You can always add the following to the top of the endpoint script instead:</p><pre>const endpointConfig = {<br>      &quot;announcementObjectName&quot;: &quot;communityAnnouncement&quot;,<br>      &quot;announcementProperty&quot;: &quot;activeAnnouncement&quot;<br>}</pre><p>In order to make the endpoint accessible from the login page, you need to add an entry to the <a href="https://backstage.forgerock.com/docs/idcloud/latest/idm-auth/authorization-and-roles.html#access-json">access control configuration</a> as follows:</p><pre>{<br>  &quot;actions&quot;: &quot;*&quot;,<br>  &quot;methods&quot;: &quot;read&quot;,<br>  &quot;pattern&quot;: &quot;endpoint/announcement/*&quot;,<br>  &quot;roles&quot;: &quot;*&quot;<br>}</pre><p>In this case, we are allowing anonymous read access (&quot;roles&quot;: &quot;*&quot;) because the endpoint needs to be accessible via the login page — i.e. before the user is authenticated.</p><p><strong>Note</strong>: technically, you could avoid the need for a dedicated endpoint, by using the default managed object endpoint at /openidm/managed/communityAnnouncement. An endpoint however provides a layer of abstraction should you want to change the underlying managed object logic in the future; in addition, an endpoint provides tightly limited access to announcements for public consumption.</p><h3>Theme</h3><p>Finally, configure the theme to include the dynamic announcement banner. In the admin portal, click on “Hosted Pages” and create a new theme.</p><p><strong>Theme header</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JbPs8bC3gB0sezDzLd5MQQ.png" /><figcaption>Theme configuration: Header</figcaption></figure><p>Next add the relevant styles and a placeholder section to the theme header:</p><pre>...<br>&lt;style&gt;<br>  .banner {<br>    width: 100%;<br>    padding: 10px;<br>    color: white;<br>    font-weight: bold;<br>  }<br>  .bannerINFO {<br>    background-color: #398445fc;<br>  }<br>  .bannerWARN {<br>    background-color: #ffae42;<br>  }<br>  .bannerERROR {<br>    background-color: #ff5e42;<br>  }<br>&lt;/style&gt;<br>&lt;div class=&quot;banner&quot; id=&quot;announcementPlaceholder&quot;&gt;&lt;/div&gt;</pre><p><strong>Theme script tags</strong></p><p>Next, add the JavaScript snippet in the script tag section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQYTqp3tSbqEn2JeGqkWow.png" /><figcaption>Theme configuration: Script Tags</figcaption></figure><p>The full script tag is as follows:</p><pre>&lt;script&gt;<br>  const ANNOUNCEMENT_AUDIENCE = &quot;customerLogin&quot;;<br><br>  const observer = new MutationObserver((mutations, obs) =&gt; {<br>    const placeholder = document.querySelector(&quot;#announcementPlaceholder&quot;);<br><br>    if (placeholder) {<br>      const announcementEndpoint = `/openidm/endpoint/announcement/${ANNOUNCEMENT_AUDIENCE}`;<br>      fetch(announcementEndpoint)<br>        .then((response) =&gt; response.json())<br>        .then((announcement) =&gt; {<br>          if (announcement.content) {<br>            placeholder.innerHTML = announcement.content;<br>            placeholder.classList.add(`banner${announcement.level}`);<br>          }<br>        });<br><br>      obs.disconnect();<br>      return;<br>    }<br>  });<br><br>  observer.observe(document, {<br>    childList: true,<br>    subtree: true,<br>  });<br>&lt;/script&gt;</pre><p>This script fetches the active message from the new announcement API we just created. The announcement is displayed via the placeholder we added to the page header. We apply the CSS style corresponding to the announcement level — i.e. information, warning or error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mccoscyjAaU5WaYd3UKUBQ.png" /><figcaption>Information message</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcCTuLQHWaE6RY03cVyhSg.png" /><figcaption>Warning message</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rx4JD-oLNFFoW_ZFzgPAg.png" /><figcaption>Error message</figcaption></figure><h3>That’s all folks</h3><p>You now have a banner in the end user login page which will display any announcements you need to make at the front door. In fact you can use this in any user journey page — not just login.</p><p>In this article we have shown how announcements may be managed via the tenant administration portal; it is also possible to delegate administration to an end user with specific privileges to manage announcements (via “<a href="https://backstage.forgerock.com/docs/idcloud/latest/idm-auth/delegated-admin.html">delegated administration</a>”).</p><p>This model may be further developed to cover localisation, timed announcements and anything else that makes life better for your customers, partners and colleagues — over to you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=848b3b948fd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PingOne Advanced Identity Cloud — Making announcements at login (intro)]]></title>
            <link>https://medium.com/@christian.brindley/pingone-advanced-identity-cloud-making-announcements-at-login-intro-012e026bc26a?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/012e026bc26a</guid>
            <category><![CDATA[forgerock-identity-cloud]]></category>
            <category><![CDATA[pingone]]></category>
            <category><![CDATA[ami]]></category>
            <category><![CDATA[aic]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Fri, 27 Sep 2024 07:21:32 GMT</pubDate>
            <atom:updated>2024-09-27T07:21:32.533Z</atom:updated>
            <content:encoded><![CDATA[<h3>PingOne Advanced Identity Cloud — Making announcements at login (intro)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*f56fooh0ovo5bN72" /></figure><h3>Introduction</h3><p>The <a href="https://www.pingidentity.com/en/platform/pingone-advanced-identity-cloud.html">PingOne Advanced Identity Cloud</a> platform acts as the front door to all of your apps and services. This makes it the logical place to provide useful information to your end users, such as planned maintenance, temporary service issues or other time sensitive messages.</p><p>One way to include such messages in your login pages is to build your own login UI, using the <a href="https://backstage.forgerock.com/docs/idcloud/latest/end-user/end-user-ux-options.html#forgerock-sdks">Ping integration SDK</a>.</p><p>A simpler, no-code approach is to take advantage of the <a href="https://backstage.forgerock.com/docs/idcloud/latest/end-user/customize-login-enduser-pages.html">extensive theming options</a> available for the standard end user UI included with the platform.</p><h3>Themes and script tags</h3><p>The PingOne AIC platform comes with a number of sample UI themes to get you started. Here is the RobRoy sample theme:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQ_nXoGzAUz7nDJuavj9ng.png" /><figcaption>RobRoy sample theme</figcaption></figure><p>In addition to being able to use your own colours, logos and styles, you can use the <a href="https://backstage.forgerock.com/docs/idcloud/latest/end-user/customize-login-enduser-pages.html#use-script-tags-in-identity-cloud-end-user-and-login-uis">script tags feature</a> to include your own snippets of JavaScript to embed in the page. This is useful for integrating into analytics platforms, cookie preference systems and so on. It is also useful for loading dynamic content such as an announcement banner for our end user messages.</p><p>To achieve this, you need to add JavaScript code to the script tags section of the theme configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*py_ppDKC6eecIsIWYwAQpQ.png" /></figure><p>You can implement a snippet which fetches announcements from a backend API and displays them as a banner on the hosted page for user login (or any other journeys you have implemented).</p><p>The banner can be integrated with an existing customer communications platform, or you can implement the backend API in the PingOne AIC platform itself, using a custom endpoint.</p><p>For example, here is the RobRoy sample login page with an announcement of an upcoming maintenance window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfeJKvvI0nKhN6VOxVBU8A.png" /><figcaption>Planned maintenance banner</figcaption></figure><p>In the <a href="https://medium.com/@christian.brindley/pingone-advanced-identity-cloud-making-announcements-at-login-how-to-848b3b948fd1">next article</a>, we’ll look at the technical details of how we can achieve this entirely within the PingOne AIC platform, via configuration alone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=012e026bc26a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Object Oriented Approach to ForgeRock Scripted Decision Nodes]]></title>
            <link>https://medium.com/@christian.brindley/an-object-oriented-approach-to-forgerock-scripted-decision-nodes-4b6bade9afe2?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b6bade9afe2</guid>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 14:48:16 GMT</pubDate>
            <atom:updated>2023-11-06T14:48:16.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*FwctsU3exk-QBKFb.png" /></figure><h3>Introduction</h3><p>The <a href="https://www.forgerock.com/identity-and-access-management-platform">ForgeRock Platform</a> includes a wide variety of journey nodes out of the box, supporting the majority of typical user journeys with little or no code.</p><p>The first approach should always be to use standard platform nodes wherever possible. In cases where there is a requirement for customer specific logic during a user journey which cannot be met using out of the box nodes, the ForgeRock platform allows this logic to be implemented via the <a href="https://backstage.forgerock.com/docs/auth-node-ref/latest/auth-node-scripted-decision.html">Scripted Decision Node</a>.</p><p>Where simple logic is required, such as logging a message to the audit trail, or setting an error message in journey state, then a standalone script will often suffice, with common functions implemented as separate libraries.</p><p>However, in the case of more complex logic, a hierarchical approach delivers greater efficiency of development and ease of maintenance. This is also a way of enforcing some of the scripting best practices discussed in the <a href="https://medium.com/@christian.brindley/best-practices-for-scripting-in-the-forgerock-platform-9a6bf4cc2767">earlier article</a> on this topic.</p><h4>Constraints</h4><p>The ForgeRock Platform uses the <a href="https://github.com/mozilla/rhino">Rhino scripting engine</a> to run JavaScript based Scripted Decision Nodes. This article describes how we can implement a class-like model using JavaScript function prototypes in order to achieve object inheritance for Scripted Decision Nodes, while working within the <a href="https://mozilla.github.io/rhino/compat/engines.html#ES2015-functions-class">constraints</a> of the Rhino engine.</p><p>This approach requires the ForgeRock Platform’s <a href="https://qa.forgerock.com/docs/docs-pr/idcloud/antora/1223/idcloud/latest/am-scripting/next-generation-scripts.html">Next Generation Scripting Environment</a>, which is included in <a href="https://www.forgerock.com/platform/identity-cloud">ForgeRock Identity Cloud</a> and the latest version of the ForgeRock self managed platform software.</p><h3>Example</h3><p>To illustrate this concept, we can use the inheritance model to implement a Scripted Decision Node which serves the following purpose:</p><ul><li>Collect a single item of data from the end user</li><li>Validate that the data is well formed</li><li>Add the data to journey state and progress to the next node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTbPK7Gt0tH6TPTSKaDK9A.png" /><figcaption>Collector Node</figcaption></figure><p>We can break a typical journey node into three layers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWDT8FHGURGeDNh2gmD_9g.png" /></figure><ul><li><strong>Base Node:</strong> the underlying node implementation, which provides the overall structure together with common functions such as an exception handler, logger and logic initiator.</li><li><strong>Utility Node:</strong> specific implementation of a node, which provides the callbacks, outcomes and processing logic for a specific use case — in this case we are collecting input from the user, and storing it in journey state.</li><li><strong>Journey Node: </strong>a scripted decision node, which implements an instance of the utility node in a user journey, and provides the configuration required for that instance.</li></ul><p>Some of the code may look a little unusual for developers familiar with modern JavaScript. This is because we are under the constraints of an ES5-like JavaScript environment, so cannot use some of the features of more modern JavaScript environments. We are not able to use the core class functionality, and are also limited in the way that we can import functions, use templates, or keywords such as let etc (the use of const can also have unexpected side effects, so we use var across the board when declaring variables).</p><h4>Base Node</h4><p>The following is an example base object for a Scripted Decision Node, implemented as a library.</p><p>demo-library-scripted-node</p><pre>// 1 - import a custom logger function<br><br>var NodeLogger = require(&quot;demo-library-node-logger&quot;).NodeLogger;<br><br>// 2 - Fix the single outcome value for all nodes<br><br>var SINGLE_OUTCOME = &quot;true&quot;;<br><br>// 3 - main scripted node &quot;class&quot;<br><br>function ScriptedNode(<br>  env,<br>  handler,<br>  nodeConfig,<br>  nodeConfigChecker,<br>  nodeOutcomes<br>) {<br>  env.logger = new NodeLogger(env.logger, env.scriptName);<br>  this.env = env;<br>  this.nodeConfig = nodeConfig;<br>  this.nodeConfigChecker = nodeConfigChecker;<br>  this.nodeOutcomes = nodeOutcomes;<br>  this.handler = handler;<br>}<br><br>// 4 - invocation entry point<br><br>ScriptedNode.prototype.process = function () {<br>  var nodeOutcomes = this.nodeOutcomes;<br>  var env = this.env;<br>  var action = env.action;<br>  var logger = env.logger;<br><br>  var errorOutcome = nodeOutcomes ? nodeOutcomes.ERROR : SINGLE_OUTCOME;<br><br>  // 5 - wrap main logic in exception handler<br><br>  try {<br>    logger.debug(&quot;Node starting&quot;);<br><br>    // 6 - all nodes should provide a function to check config<br><br>    if (!this.nodeConfigChecker(this.nodeConfig, env.logger)) {<br>      logger.error(&quot;Bad config - config check failed&quot;);<br>      action.goTo(errorOutcome);<br>      return;<br>    }<br><br>    // 7 - unless it is a single outcome, should include an ERROR outcome<br><br>    if (nodeOutcomes &amp;&amp; !nodeOutcomes.ERROR) {<br>      logger.error(&quot;Bad config - no ERROR outcome&quot;);<br>      action.goTo(errorOutcome);<br>      return;<br>    }<br><br>    // 8 - run the implementation specific handler<br><br>    this.handler(env);<br>  } catch (e) {<br>    // In the case of an exception, fail with error<br><br>    logger.error(&quot;Exception &quot; + e);<br>    logger.error(&quot;Stack trace &quot; + e.stack);<br>    action.goTo(errorOutcome);<br>  }<br>};<br><br>module.exports.ScriptedNode = ScriptedNode;<br>module.exports.SINGLE_OUTCOME = SINGLE_OUTCOME;</pre><p>This may be broken down as follows:</p><pre>// 1 - import a custom logger function<br><br>var NodeLogger = require(&quot;demo-library-node-logger&quot;).NodeLogger;</pre><p>We import a custom logger which is going to make it easy to find any messages in the system log, and add anything else of use to each log entry. We override the default system logger with this custom logger, so that calling nodes can call logger as normal.</p><pre>// 2 - Fix the single outcome value for all nodes<br><br>var SINGLE_OUTCOME = &quot;true&quot;;</pre><p>Nodes may be single or multiple outcome. Single outcome nodes are used where there is only one path to follow after the node has completed. The above logic means that we fix the outcome to true for all single outcome nodes for consistency. In the case of multiple outcome nodes, the list of possible outcomes is provided as part of the instantiation of the base “class”.</p><pre>// 3 - main scripted node &quot;class&quot;<br><br>function ScriptedNode(<br>  env,<br>  handler,<br>  nodeConfig,<br>  nodeConfigChecker,<br>  nodeOutcomes<br>) {<br>  env.logger = new NodeLogger(env.logger, env.scriptName);<br>  this.env = env;<br>  this.nodeConfig = nodeConfig;<br>  this.nodeConfigChecker = nodeConfigChecker;<br>  this.nodeOutcomes = nodeOutcomes;<br>  this.handler = handler;<br>}</pre><p>This is the instantiation point for the Scripted Node, emulating a JavaScript class in its behaviour upon invocation. More on the parameters later when describing the example utility node.</p><pre>// 5 - wrap main logic in exception handler<br><br>  try {<br>...</pre><p>The base node logic includes an exception handler which will catch any exceptions thrown by the caller. This provides a safe and consistent exception path for all nodes, so that this situation can be handled in a controlled manner in the journey.</p><pre>// 6 - all nodes should provide a function to check config<br><br>    if (!this.nodeConfigChecker(this.nodeConfig, env.logger)) {<br>      logger.error(&quot;Bad config - config check failed&quot;);<br>      action.goTo(errorOutcome);<br>      return;<br>    }</pre><p>The base node enforces validation of configuration passed in from the journey. The logic itself is provided by the calling utility node, as we’ll see later on.</p><pre>// 7 - unless it is a single outcome, should include an ERROR outcome</pre><p>If the calling node is a single outcome node, then we will continue along the journey in the case of error conditions. If it is a multiple outcome node then we enforce the presence of a dedicated error outcome so that it is handled gracefully in the journey.</p><pre>// 8 - run the implementation specific handler<br><br>    this.handler(env);</pre><p>At this point, the base node “class” passes control to the calling utility node, feeding in the node environment and its associated bindings.</p><h4>Utility Node — String collector</h4><p>The following is an example utility node for collecting data from the end user, and storing it in shared state. If configured with a regular expression to match the data with, the node will block the journey if the user enters data which fails the match.</p><p>demo-library-collect-input-node</p><pre>var ScriptedNode = require(&quot;demo-library-scripted-node&quot;).ScriptedNode;<br>var SINGLE_OUTCOME = require(&quot;demo-library-scripted-node&quot;).SINGLE_OUTCOME;<br><br>// 1 - document usage<br><br>//  CollectInputNode<br>//<br>//  For use in a scripted decision node to collect input from the user agent<br>//  and store the value in shared state. Optionally perform data validation<br>//  via regular expression<br>//<br>//  - Configuration parameters<br>//<br>//  label: Text to use for input field prompt<br>//  stateVariable: Name of journey state variable to store value<br>//  format:<br>//    regex: Regular expression to apply<br>//    errorMessage: Message to display if regular expression match fails<br>//<br>//  - Example<br>//<br>//  --------------------------------------------------------------------<br>//  var CollectInputNode =<br>//    require(&quot;demo-library-collect-input-node&quot;).CollectInputNode;<br>//<br>//  var nodeConfig = {<br>//    label: &quot;fieldLabelMobileNumber&quot;,<br>//    stateVariable: &quot;mobileNumber&quot;,<br>//    format: {<br>//      regex: &quot;^\\+?([0-9\\- \\(\\)])*$&quot;,<br>//      errorMessage: &quot;messageInvalidMobileNumber&quot;,<br>//    },<br>//  };<br>//  <br>//  new CollectInputNode(this, nodeConfig).process();<br>//  --------------------------------------------------------------------<br><br>/*<br> * CollectInputNode<br> * var nodeConfig = {<br> *   label: &quot;fieldLabelMobileNumber&quot;,<br> *   stateVariable: &quot;mobileNumber&quot;,<br> *   format: {<br> *     regex: &quot;^\\+?([0-9\\- \\(\\)])*$&quot;,<br> *     errorMessage: &quot;messageInvalidMobileNumber&quot;,<br> *   },<br> * };<br> */<br><br>// 2 - function for checking provided config<br><br>function nodeConfigChecker(nodeConfig, logger) {<br>  logger.debug(&quot;Checking config&quot;);<br>  if (!nodeConfig.label || !nodeConfig.stateVariable) {<br>    logger.error(&quot;Missing required config&quot;);<br>    return false;<br>  }<br><br>  if (<br>    nodeConfig.format &amp;&amp;<br>    (!nodeConfig.format.regex || !nodeConfig.format.errorMessage)<br>  ) {<br>    logger.error(&quot;Bad format config&quot;);<br>    return false;<br>  }<br><br>  return true;<br>}<br><br>// 3 - main logic handler<br><br>function handler(env) {<br>  var logger = env.logger;<br>  var callbacks = env.callbacks;<br>  var callbacksBuilder = env.callbacksBuilder;<br>  var nodeConfig = env.nodeConfig;<br>  var nodeState = env.nodeState;<br>  var action = env.action;<br><br>  logger.debug(&quot;CollectInputNode&quot;);<br><br>  if (callbacks.isEmpty()) {<br>    logger.debug(&quot;Building initial callback&quot;);<br><br>    callbacksBuilder.stringAttributeInputCallback(<br>      nodeConfig.stateVariable,<br>      nodeConfig.label,<br>      &quot;&quot;,<br>      false<br>    );<br><br>    return;<br>  }<br><br>  var inputValue = callbacks.getStringAttributeInputCallbacks().get(0);<br>  logger.debug(&quot;Got input &quot; + inputValue);<br><br>  if (nodeConfig.format &amp;&amp; !inputValue.match(nodeConfig.format.regex)) {<br>    logger.warn(&quot;Value did not match regex: &quot; + nodeConfig.format.regex);<br><br>    var failedPolicy = {<br>      policyRequirement: &quot;CUSTOM&quot;,<br>      params: {<br>        message: nodeConfig.format.errorMessage,<br>      },<br>    };<br><br>    callbacksBuilder.stringAttributeInputCallback(<br>      nodeConfig.stateVariable,<br>      nodeConfig.label,<br>      inputValue,<br>      false,<br>      [JSON.stringify(failedPolicy)]<br>    );<br><br>    return;<br>  }<br><br>  nodeState.putShared(nodeConfig.stateVariable, inputValue);<br>  action.goTo(SINGLE_OUTCOME);<br>}<br><br>// 4 - utility node &quot;class&quot; to call from the journey.<br><br>function CollectInputNode(env, nodeConfig) {<br>  ScriptedNode.call(this, env, handler, nodeConfig, nodeConfigChecker);<br>}<br><br>// 5 - overlay with extended constructor<br><br>CollectInputNode.prototype = Object.create(ScriptedNode.prototype);<br>CollectInputNode.prototype.constructor = CollectInputNode;<br><br>module.exports.CollectInputNode = CollectInputNode;</pre><p>This is implemented as a library, broken down as follows:</p><pre>// 1 - document usage<br><br>//  CollectInputNode<br>//<br>//  For use in a scripted decision node to collect input from the user agent<br>//  and store the value in shared state. Optionally perform data validation<br>//  via regular expression<br>//<br>...</pre><p>The library code should be self documenting, with expected configuration and example usage.</p><p>The caller provides the journey specific config, as we’ll see when we come to the journey node.</p><pre>// 2 - function for checking provided config<br><br>function nodeConfigChecker(nodeConfig, logger) {<br>  logger.debug(&quot;Checking config&quot;);<br>  if (!nodeConfig.label || !nodeConfig.stateVariable) {<br>    logger.error(&quot;Missing required config&quot;);<br>    return false;<br>  }<br><br>  if (<br>    nodeConfig.format &amp;&amp;<br>    (!nodeConfig.format.regex || !nodeConfig.format.errorMessage)<br>  ) {<br>    logger.error(&quot;Bad format config&quot;);<br>    return false;<br>  }<br><br>  return true;<br>}</pre><p>The utility node provides a config checking function to the base node to verify the configuration provided by the journey node.</p><pre>// 3 - main logic handler<br><br>function handler(env) {<br>  var logger = env.logger;<br>  var callbacks = env.callbacks;<br>  var callbacksBuilder = env.callbacksBuilder;<br>  var nodeConfig = env.nodeConfig;<br>  var nodeState = env.nodeState;<br>  var action = env.action;<br>...</pre><p>This is the main logic for the utility node. This function is passed into the base node, which in turn executes the logic within a try-catch exception handler.</p><p>The script environment is passed into the handler so that all the environment bindings are available. It is standard practice to explicitly assign bindings to local variables for clarity and to remove any ambiguity; technically we could wrap the logic in with (env) {} but this is now considered <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with">bad practice</a>.</p><pre>// 4 - utility node &quot;class&quot; to call from the journey.<br><br>function CollectInputNode(env, nodeConfig) {<br>  ScriptedNode.call(this, env, handler, nodeConfig, nodeConfigChecker);<br>}<br><br>// 5 - overlay with extended constructor<br><br>CollectInputNode.prototype = Object.create(ScriptedNode.prototype);<br>CollectInputNode.prototype.constructor = CollectInputNode;</pre><p>This is where the magic happens to inherit and extend the base node “class”. We call the parent “class” with</p><ul><li>this ourself</li><li>env the scripting environment we got from the calling scripted decision node</li><li>handler the handler function for this utility node</li><li>nodeConfig the config we got from the calling scripted decision node</li><li>nodeConfigChecker the function which implements the logic to check the incoming config</li></ul><p>Note that we do not provide the list of possible node outcomes, because this is a single outcome node, so the base node will provide that for us.</p><p>In the case of nodes which provide multiple outcomes, the constructor function would look something like</p><pre>var nodeOutcomes = {<br>  ERROR: &quot;error&quot;,<br>  CORRECT: &quot;correct&quot;,<br>  INCORRECT: &quot;incorrect&quot;<br>}<br>...<br>function CheckOtpNode(env, nodeConfig) {<br>  ScriptedNode.call(this, env, handler, nodeConfig, nodeConfigChecker, nodeOutcomes);<br>}<br>...</pre><h4>Journey Node</h4><p>Finally, we are going to invoke the CollectInputNode utility node from our journey, using a Scripted Decision Node to provide the configuration.</p><p>demo-collect-mobile</p><pre>var CollectInputNode =<br>  require(&quot;demo-library-collect-input-node&quot;).CollectInputNode;<br><br>var nodeConfig = {<br>  label: &quot;fieldLabelMobileNumber&quot;,<br>  stateVariable: &quot;mobileNumber&quot;,<br>  format: {<br>    regex: &quot;^\\+?([0-9\\- \\(\\)])*$&quot;,<br>    errorMessage: &quot;messageInvalidMobileNumber&quot;,<br>  },<br>};<br><br>new CollectInputNode(this, nodeConfig).process();</pre><p>This reduces scripted decision nodes to their bare minimum — essentially just the journey specific config, with the main logic implemented externally via a relatively static set of libraries which can be distributed and maintained independently of journeys.</p><h4>Supporting functions</h4><p>For completeness, here is the library script containing the custom logger which we use in the base node to override the standard platform logger:</p><p>demo-library-node-logger</p><pre>function NodeLogger(logger, scriptName) {<br>  this.logger = logger;<br>  this.scriptName = scriptName;<br>  this.logPrefix = &quot;***&quot; + scriptName + &quot; &quot;;<br>}<br><br>NodeLogger.prototype.debug = function (message) {<br>  this.logger.debug(this.logPrefix.concat(message));<br>};<br><br>NodeLogger.prototype.warn = function (message) {<br>  this.logger.warn(this.logPrefix.concat(message));<br>};<br><br>NodeLogger.prototype.error = function (message) {<br>  this.logger.error(this.logPrefix.concat(message));<br>};<br><br>module.exports.NodeLogger = NodeLogger;</pre><h3>Conclusion</h3><p>The object oriented approach provides the usual benefits of inheritance, encapsulation, modularity and reuse. In the context of Scripted Decision Nodes, it also provides a way to support and enforce best practices, which in turn leads to more consistent and robust user journeys.</p><p>The logic required to achieve this goal may be somewhat more convoluted than a standalone Scripted Decision Node. However, this complexity is limited to the library scripts that make up the node, leaving minimal scripting at the journey level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b6bade9afe2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices for Scripting in the ForgeRock Platform]]></title>
            <link>https://medium.com/@christian.brindley/best-practices-for-scripting-in-the-forgerock-platform-9a6bf4cc2767?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a6bf4cc2767</guid>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 14:47:42 GMT</pubDate>
            <atom:updated>2023-11-06T14:47:42.020Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>One of the standout features of the ForgeRock Platform is its extensibility: you can meet pretty much any business requirement via its pluggable architecture. The core functions of authentication, authorisation and identity management are handled by the open standards based core platform; the “last mile” of integration into a specific environment can be achieved via Java or JavaScript based extensions.</p><p>Note that platform customisation should be undertaken wisely. If there is a way to achieve the same business goals with out of the box features, or these goals can be adjusted with no negative impact, then out of the box is the way to go. Wherever it is necessary to meet specific requirements via customer specific extensions, these extensions will be the responsibility of the customer to maintain and support.</p><h3>The Scripted Decision Node</h3><p>The ForgeRock Platform provides numerous extension points, covering authentication, authorisation, token profile, identity lifecycle management and much more besides. This article focuses specifically on the <a href="https://backstage.forgerock.com/docs/idcloud/latest/am-scripting/scripting-api.html#scripted_decision_node_api">Scripted Decision Node</a>, which allows customers to add their own specific logic to authentication journeys using JavaScript. This is arguably the most heavily used extension point, with JavaScript as the language option for both <a href="https://backstage.forgerock.com/docs/idcloud/latest/overview.html">ForgeRock Identity Cloud</a> and customers’ own deployments of the <a href="https://backstage.forgerock.com/docs/platform/latest">ForgeRock Platform</a>. Although we are focusing on scripted decision nodes, the same general principles apply to all uses of the <a href="https://backstage.forgerock.com/docs/idcloud/latest/am-scripting/scripting-api.html">Scripting API</a>.</p><h3>Journeys and Nodes</h3><p>Customers implement a wide variety of journeys via the ForgeRock platform, covering not just authentication, but also registration, credential recovery, identity management and more. Each journey consists of a number of steps, which may entail end user interaction (such as prompting for a verification code) or backend processing logic (such as looking up user profile information or interacting with a risk API). Each step in the journey is termed a “node”, which may be an out of the box node from the ForgeRock catalogue, or a custom node developed by the customer for a specific use case.</p><h3>Best Practices</h3><p>When creating scripted nodes, customers should naturally apply the general best practices for developing in JavaScript. This article focuses on the aspects of JavaScript development specific to the ForgeRock Platform environment, over and above general best practices for developing in JavaScript.</p><p>Note that the ForgeRock Platform uses the <a href="https://backstage.forgerock.com/docs/idcloud/latest/am-scripting/scripting-env.html#scripting_engine">Mozilla Rhino</a> scripting engine. This means that there are some differences between the ForgeRock environment and a typical JavaScript ES6 or higher environment, which means that not all general best practices will apply. For example, the use of let and const when declaring variables does not apply in the ForgeRock environment.</p><h3>Example Script</h3><p>We will start with a simple scripted decision node as an example. This node prompts for a verification code, such as a 6 digit one time password, and compares it against a value stored in journey state — e.g. an OTP that was generated and delivered via SMS in an earlier step.</p><pre>// 1. Licence details/disclaimer<br><br>/*<br> * The code provided hereunder is provided free-of-charge, and shall be deemed ForgeRock &quot;Sample Code&quot;<br> * as defined in the relevant governing agreement with ForgeRock.<br> *<br> * This Sample Code is to be used exclusively in connection with ForgeRock’s software or services.<br> * ForgeRock only offers ForgeRock software or services to legal entities who have entered into a<br> * binding license agreement with ForgeRock.<br> *<br> * THE CODE HEREUNDER IS PROVIDED “AS IS” AND WITHOUT WARRANTY OF ANY KIND. SUCH CODE IS EXPRESSLY<br> * EXCLUDED FROM FORGEROCK&#39;S INDEMNITY OR SUPPORT OBLIGATIONS, IF ANY, PURSUANT TO THE RELEVANT<br> * GOVERNING AGREEMENT. FORGEROCK AND ITS LICENSORS EXPRESSLY DISCLAIM ALL WARRANTIES, WHETHER<br> * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF<br> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND ANY WARRANTY OF NON-INFRINGEMENT.<br> * FORGEROCK SHALL NOT HAVE ANY LIABILITY ARISING OUT OF OR RELATING TO ANY USE, IMPLEMENTATION OR<br> * CONFIGURATION OF THE SAMPLE CODE HEREUNDER.<br> */<br><br>// 2. Config at the top<br><br>var nodeConfig = {<br>  prompt: &quot;labelVerificationCode&quot;,<br>  // 3. Use locale config for user facing messages<br>  failureMessage: &quot;messageVerificationCodeIncorrect&quot;,<br>  stateVariable: &quot;oneTimePassword&quot;,<br>};<br><br>// 4. Define all outcomes<br><br>var nodeOutcomes = {<br>  CORRECT: &quot;correct&quot;,<br>  INCORRECT: &quot;incorrect&quot;,<br>  ERROR: &quot;error&quot;,<br>};<br><br>// 5. Run main body in an Immediately Executed Function<br><br>(function () {<br>  // 6. Wrap the body in a try/catch with an error outcome on exception<br><br>  try {<br>    if (callbacks.isEmpty()) {<br>      // 7. Keep logging at debug unless it&#39;s an error - don&#39;t include PII data in error messages<br>      logger.debug(&quot;Building callbacks&quot;);<br>      var errorMessage = nodeState.get(&quot;errorMessage&quot;);<br><br>      if (errorMessage &amp;&amp; errorMessage !== &quot;&quot;) {<br>        logger.error(&quot;Showing error message&quot;);<br>        callbacksBuilder.textOutputCallback(2, errorMessage);<br>        nodeState.putShared(&quot;errorMessage&quot;, &quot;&quot;);<br>      }<br><br>      callbacksBuilder.textInputCallback(nodeConfig.label);<br><br>      return;<br>    }<br><br>    // 8. Use transient state where appropriate<br><br>    var verificationCode = nodeState.get(nodeConfig.stateVariable);<br><br>    if (!verificationCode || verificationCode === &quot;&quot;) {<br>      logger.error(&quot;No code in shared state&quot;);<br>      action.goTo(nodeOutcomes.ERROR);<br>      return;<br>    }<br><br>    var inputValue = callbacks.getTextInputCallbacks().get(0);<br>    logger.error(&quot;Got value &quot; + inputValue);<br><br>    if (inputValue !== verificationCode) {<br>      nodeState.putShared(&quot;errorMessage&quot;, nodeConfig.failureMessage);<br><br>      // 9. Use action, not outcome<br>      action<br>        .goTo(nodeOutcomes.INCORRECT)<br>        .withErrorMessage(nodeConfig.failureMessage);<br>      return;<br>    }<br><br>    action.goTo(nodeOutcomes.CORRECT);<br>  } catch (e) {<br>    // 10. Include as much information as possible for errors<br>    logger.error(&quot;Exception &quot; + e);<br>    logger.error(&quot;Stack trace &quot; + e.stack);<br>    action.goTo(nodeOutcomes.ERROR);<br>  }<br>})();</pre><p>This simple script illustrates some basic guiding principles for writing scripted decision nodes for the ForgeRock platform, as follows:</p><pre>// 1. Licence details/disclaimer</pre><p>A script is obviously code, and therefore it should be clear who wrote it and under what kind of agreement. In this case, we are using the standard ForgeRock sample code disclaimer.</p><pre>// 2. Config at the top<br><br>var nodeConfig = {<br>  prompt: &quot;labelVerificationCode&quot;,<br>  // 3. Use locale config for user facing messages<br>  failureMessage: &quot;messageVerificationCodeIncorrect&quot;,<br>  stateVariable: &quot;oneTimePassword&quot;,<br>};</pre><p>Any configuration data, such as journey state variable names, message labels, environment variable names etc, have to be defined in the script itself, as the ForgeRock platform does not provide a way to define such configuration outside the script. This configuration data should be near the top of the script for clarity, and kept together in one configuration object for ease of reference elsewhere in the script — e.g. nodeConfig.failureMessage.</p><pre>// 3. Use locale config for user facing messages</pre><p>Any user facing messages, such as error messages or field labels, should be locale friendly — i.e. not hard coded in a specific language. By using message tags such as labelVerificationCode, user facing text can be translated according to browser locale via the platform locale override framework.</p><pre>// 4. Define all outcomes</pre><p>A scripted decision node can have any number of outcomes, which are used in the journey to route to the next step accordingly. All possible outcomes should be defined within a single object near the top of the script, to make it easy to capture all outcomes for the journey configuration. In this case, we have three possible outcomes</p><ul><li>correct — the code entered by the user matches the code we generated earlier and stored in journey state</li><li>incorrect — the code entered by the user does not match the code in journey state</li><li>error — there was a processing error, such as unexpected journey state or a script exception</li></ul><pre>// 5. Run main body in an Immediately Invoked Function Expression</pre><p>The main logic of the script should be executed as an <a href="https://developer.mozilla.org/en-US/docs/Glossary/IIFE">Immediately Invoked Function Expression</a> (IIFE). In addition to the general benefits of an IIFE, such as clear scope and type coercion, this approach allows quick termination of processing via a return statement, rather than via a complex series of if/then/else clauses, making the code easier to understand and maintain.</p><pre>// 6. Wrap the body in a try/catch with an error outcome on exception</pre><p>A script should never terminate unexpectedly, but the possibility of a script exception should always be handled gracefully. This requires a try/catch block around the main script logic, which sets an error outcome in the case of an exception. This error can then be handled via the journey, such as via a retry or a user friendly error message, rather than the journey terminating abnormally along with the script.</p><pre>// 7. Keep logging at debug unless it&#39;s an error - don&#39;t include PII data in error messages</pre><p>Logging is an important tool in debugging and triaging issues that may occur during processing. However, it also has the potential to leak sensitive information in a live environment, for example by printing personal information or security credentials to system logs.</p><p>Log messages should be at debug level unless they are true errors which need to be recorded in live environments for the purposes of triage etc. Error messages should contain no sensitive data. In the case of ForgeRock Identity Cloud, log messages at debug level are only included in the development environment: customers deploying the self managed ForgeRock platform are advised to take a similar approach.</p><pre>// 8. Use transient state where appropriate</pre><p>Individual nodes within a journey can share information via journey state — i.e. by setting and reading state variables that are persisted between steps in a journey.</p><p>When setting variables in state, there are two types of state you can reference via the nodeState interface</p><ul><li>Shared state, which is persisted for the duration of the journey</li><li>Transient state, which by default is persisted only until the next callback — i.e. user agent interaction</li></ul><p>If you are setting a variable which will not be required after the next callback, then it should be stored in transient state. This will reduce the size of the authId JWT used for stateless journeys, and share less information outside the platform backend. For example, you may have a node which discovers the client IP address, which is then passed to the next node via transient state for storing against the user profile, after which the client IP address is never used again within the journey.</p><p>If you are setting a variable which contains a sensitive value, such as the verification code used in the example script above, then this should also be stored in transient state. If this value is required after the next callback by another scripted decision node, then you should make sure you include the variable name as an input variable in the later scripted decision node. This will automatically put the variable into secure state, which is persisted through callbacks. More details on this are provided in the <a href="https://backstage.forgerock.com/docs/idcloud/latest/am-authentication/scripting-api-node.html#scripting-api-node-nodeState">ForgeRock documentation</a>.</p><pre>// 9. Use action, not outcome</pre><p>On completion, a scripted decision node passes control back to the journey, specifying either an <em>outcome</em> such as correct in the above example, or a <em>callback</em> request for user interaction before being called again, such as prompting the user for a verification code.</p><p>Callbacks are requested via the callbacksBuilder interface. The outcome can be passed via the outcome binding like this</p><p>outcome = nodeOutcomes.CORRECT</p><p>or via the action binding like this</p><p>action.goTo(nodeOutcomes.CORRECT)</p><p>It is good practice always to use the action binding: this removes any ambiguity over the precedence of action vs. outcome, and also provides consistency when attaching additional operations via the action methods such as</p><p>action.goTo(nodeOutcomes.ERROR).withErrorMessage(nodeConfig.failureMessage);</p><pre>// 10. Include as much information as possible for errors</pre><p>When there is an error, include as much information as possible about the cause (although as above, avoid including sensitive data within the error message). In the case of issues in a live environment, the error messages in your script will often be the only meaningful information available for triage and remediation.</p><h3>Conclusion</h3><p>We have explored some of the guiding principles for developing robust and maintainable scripts for use in the ForgeRock Platform, focusing specifically on JavaScript based Scripted Decision Nodes. This is not an exhaustive list of best practices, and does not cover more advanced use cases such as calling external REST services etc, but is intended to provide a solid starting point for designing and building scripts in the ForgeRock environment.</p><p>In the <a href="https://medium.com/@christian.brindley/forgerock-scripted-decision-nodes-an-object-oriented-approach-4b6bade9afe2">next article</a>, we will explore how we can formulate and bake in some of these best practices through the use of the new ForgeRock script libraries.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a6bf4cc2767" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Delivering RFC9068 compliant OAuth2 Access Tokens via the ForgeRock Identity Platform]]></title>
            <link>https://medium.com/@christian.brindley/delivering-rfc9068-compliant-oauth2-access-tokens-via-the-forgerock-identity-platform-14c7e25079ca?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/14c7e25079ca</guid>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 13:32:26 GMT</pubDate>
            <atom:updated>2023-04-28T15:46:09.176Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDFqKD9RGWFF7aEnMfN50Q.png" /></figure><p>This article focuses on how to configure the ForgeRock Identity Platform to issue JWT based access tokens in compliance with <a href="https://www.rfc-editor.org/rfc/rfc9068.txt">RFC 9068</a>.</p><h3>Introduction</h3><p>In the early days of <a href="https://datatracker.ietf.org/doc/html/rfc6749">OAuth2</a>, access tokens were usually opaque strings, consisting of unique random values generated by the authorisation server — e.g</p><pre>sbQZuveFumUDV5R1vVBl6QAGNB8</pre><p>When an OAuth2 resource server is presented with such an access token, it needs to connect to the authorisation server introspection endpoint in order to check the token details before allowing access.</p><p>Over time, OAuth2 implementations have started to use access tokens which are no longer opaque, but consist of self contained signed data which can be introspected locally by the resource server: this saves the overhead of querying the authorisation server for every token.</p><p>The most common choice of format for such access tokens is the JSON Web Token (<a href="https://datatracker.ietf.org/doc/html/rfc7519">JWT</a>): in this case the access token includes signed claims about the authorised subject, scope and validity—similar to ID tokens per the <a href="https://openid.net/specs/openid-connect-core-1_0.html#IDToken">OpenID Connect standard</a>. For example, here is a JWT based access token generated by the ForgeRock OAuth2 provider:</p><pre>eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5ZWIzYzQyYi1kMjIwLTRiMzc<br>tODQ0NC1jNmY5ZTM5ODBkYjciLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV<br>0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiNDk3ZTNjYTEtMTA5Zi00YjY5LTg2MTk<br>tNTU1ZTNmZDZjMzg2LTE3NDM0NTEiLCJzdWJuYW1lIjoiOWViM2M0MmItZDIyMC00YjM3LTg<br>0NDQtYzZmOWUzOTgwZGI3IiwiaXNzIjoiaHR0cHM6Ly9vcGVuYW0tYnJpbmRsZXkuZm9yZ2V<br>ibG9ja3MuY29tOjQ0My9hbS9vYXV0aDIvcmVhbG1zL3Jvb3QvcmVhbG1zL2FscGhhIiwidG9<br>rZW5OYW1lIjoiYWNjZXNzX3Rva2VuIiwidG9rZW5fdHlwZSI6IkJlYXJlciIsImF1dGhHcmF<br>udElkIjoidmxqTUFQNGdmbW5sOURTVFVEdmJyRUZzTmRZIiwiYXVkIjoiY2xpZW50OTA2OCI<br>sIm5iZiI6MTY4MjUxMDg3MCwiZ3JhbnRfdHlwZSI6ImF1dGhvcml6YXRpb25fY29kZSIsInN<br>jb3BlIjpbInBob3RvOnJlYWQiXSwiYXV0aF90aW1lIjoxNjgyNTEwODA1LCJyZWFsbSI6Ii9<br>hbHBoYSIsImV4cCI6MTY4MjUxNDQ3MCwiaWF0IjoxNjgyNTEwODcwLCJleHBpcmVzX2luIjo<br>zNjAwLCJqdGkiOiJwY2FaM0hlemVxR2pINGhKTGx1UWxlNm5yNm8ifQ.0sTQlgw9YG5jO8bX<br>7mV57pw3aEqNdls13-eM-giUYKc</pre><p>Once the signature is checked, the token can be decoded and its JSON payload inspected for authorised subject, scope etc:</p><pre>{<br>  &quot;sub&quot;: &quot;9eb3c42b-d220-4b37-8444-c6f9e3980db7&quot;,<br>  &quot;cts&quot;: &quot;OAUTH2_STATELESS_GRANT&quot;,<br>  &quot;auth_level&quot;: 0,<br>  &quot;auditTrackingId&quot;: &quot;497e3ca1-109f-4b69-8619-555e3fd6c386-1743451&quot;,<br>  &quot;subname&quot;: &quot;9eb3c42b-d220-4b37-8444-c6f9e3980db7&quot;,<br>  &quot;iss&quot;: &quot;https://openam-xxxxxx.forgeblocks.com:443/am/oauth2/realms/root/realms/alpha&quot;,<br>  &quot;tokenName&quot;: &quot;access_token&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;authGrantId&quot;: &quot;vljMAP4gfmnl9DSTUDvbrEFsNdY&quot;,<br>  &quot;aud&quot;: &quot;client9068&quot;,<br>  &quot;nbf&quot;: 1682510870,<br>  &quot;grant_type&quot;: &quot;authorization_code&quot;,<br>  &quot;scope&quot;: [<br>    &quot;photo:read&quot;<br>  ],<br>  &quot;auth_time&quot;: 1682510805,<br>  &quot;realm&quot;: &quot;/alpha&quot;,<br>  &quot;exp&quot;: 1682514470,<br>  &quot;iat&quot;: 1682510870,<br>  &quot;expires_in&quot;: 3600,<br>  &quot;jti&quot;: &quot;pcaZ3HezeqGjH4hJLluQle6nr6o&quot;<br>}</pre><h3>RFC 9068</h3><p>Recognising the industry direction towards JWT based access tokens, a standard JWT profile was proposed via <a href="https://datatracker.ietf.org/doc/html/rfc9068">RFC 9068 — JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens</a>. The intention is to make JWT based access tokens interoperable across multiple authorisation platforms and resource servers.</p><h3>ForgeRock client side tokens</h3><p>ForgeRock has supported JWT based access tokens for some years now, via the <a href="https://backstage.forgerock.com/docs/idcloud-am/latest/oauth2-guide/client-side-tokens.html">client side access token</a> feature which predates RFC 9068.</p><p>Although the default JWT profile provided by ForgeRock is largely in line with RFC 9068, there are some minor differences.</p><p>To illustrate the profile required by the RFC, this is the JSON payload of the example given in the RFC 9068 specification:</p><pre>{<br>  &quot;iss&quot;: &quot;https://authorization-server.example.com/&quot;,<br>  &quot;sub&quot;: &quot;5ba552d67&quot;,<br>  &quot;aud&quot;: &quot;https://rs.example.com/&quot;,<br>  &quot;exp&quot;: 1639528912,<br>  &quot;iat&quot;: 1618354090,<br>  &quot;jti&quot;: &quot;dbe39bf3a3ba4238a513f51d6e1691c4&quot;,<br>  &quot;client_id&quot;: &quot;s6BhdRkqt3&quot;,<br>  &quot;scope&quot;: &quot;openid profile reademail&quot;<br>}</pre><p>The default ForgeRock token profile differs from the RFC in the following respects:</p><ul><li>The <strong>aud</strong> claim is set to the OAuth2 client ID, rather than the requested resource</li><li>There is no <strong>client_id</strong> claim</li><li>The <strong>scope</strong> claim is a JSON array of strings, rather than a single string consisting of a space separated list of scopes</li></ul><p>Fortunately the ForgeRock platform supports extensive customisation of access tokens, allowing you to provide your own logic for building any profile required. We are going to use this feature to configure the ForgeRock OAuth2 provider to issue tokens with a payload in compliance with the RFC.</p><h4>Caveats</h4><p>This article does not cover the following areas of the RFC:</p><p><strong>a. JWT header<br></strong>RFC 9068 specifies that the <strong>typ</strong> claim in the JWT header is set to at+JWT to flag the JWT unambiguously as an access token — e.g.</p><pre>{<br>  &quot;typ&quot;: &quot;at+JWT&quot;,<br>  &quot;alg&quot;: &quot;RS256&quot;,<br>  &quot;kid&quot;: &quot;RjEwOwOA&quot;<br>}</pre><p>ForgeRock client side tokens are issued with the <strong>typ</strong> header set to the standard value of JWT — i.e.</p><pre>&quot;typ&quot;: &quot;JWT&quot;</pre><p>There is currently no way to override the JWT header in the ForgeRock platform, so we are relying on the resource server to be relaxed about this specific aspect of the RFC requirements.</p><p><strong>b. Authorisation endpoint<br></strong>The <strong>resource</strong> parameter referenced in RFC 9068 can be used in two places according to <a href="https://www.rfc-editor.org/rfc/rfc8707.html">RFC 8707</a>:</p><ul><li>Requests to the authorisation endpoint</li><li>Requests to the token endpoint</li></ul><p>In this article we are focusing on the token endpoint — i.e. the point at which the token is issued. We are not focusing on the initial call to the authorisation endpoint — so we are not trying to include the requested resource in an explicit consent step, or correlating the resource in the original authorisation request with the resource in the token request (although we will still be ensuring that the client is authorised for the requested resource).</p><h3>The Access Token Modification script</h3><p>In the ForgeRock platform, OAuth2 access tokens can be profiled via the Access Token Modification extension point. You can provide your own Java class, or script the logic via Groovy or JavaScript. For the purposes of this exercise, we are going to use the JavaScript option, because this is simple to implement and compatible with all deployment models of the ForgeRock platform, including <a href="https://backstage.forgerock.com/docs/idcloud/latest/home.html">ForgeRock Identity Cloud</a>.</p><p>We will be using the following sample token modification script:</p><pre>function _debug(message) {<br>  logger.message(&quot;***[&quot; + scriptName + &quot;] &quot; + message);<br>}<br><br>function _error(message) {<br>  logger.error(&quot;***[&quot; + scriptName + &quot;] &quot; + message);<br>}<br><br>var OAUTH2_RESOURCE_PARAMETER = &quot;resource&quot;;<br><br>var javaImports = JavaImporter(<br>  org.forgerock.oauth2.core.exceptions.InvalidRequestException<br>);<br><br>(function () {<br>  _debug(&quot;Starting&quot;);<br>  try {<br>    // 1. Read in the request parameter of the OAuth2 request<br>    var requestedAudience = requestProperties.requestParams.get(<br>      OAUTH2_RESOURCE_PARAMETER<br>    );<br>    if (!requestedAudience) {<br>      _debug(&quot;No resource parameter - continuing without changing&quot;);<br>      return;<br>    }<br><br>    // 2. Validate the resource<br>    requestedAudience = String(requestedAudience.get(0));<br><br>    _debug(&quot;Requested audience: &quot; + requestedAudience);<br>    var allowedAudiences = JSON.parse(<br>      clientProperties.customProperties.allowedAudiences<br>    );<br>    _debug(&quot;Allowed audiences: &quot; + allowedAudiences);<br>    if (!allowedAudiences.includes(requestedAudience)) {<br>      _error(&quot;Requested audience not permitted: &quot; + requestedAudience);<br>      throw javaImports.InvalidRequestException(<br>        &quot;Requested audience not permitted: &quot; + requestedAudience<br>      );<br>    }<br><br>    // 3. Add the client_id claim with the requesting OAuth2 client<br>    accessToken.setField(&quot;client_id&quot;, clientProperties.clientId);<br><br>    // 4. Override the aud claim with the requested resource<br>    accessToken.setField(&quot;aud&quot;, requestedAudience);<br><br>    // 5. Flatten the scope value<br>    accessToken.setField(&quot;scope&quot;, accessToken.getScope().toArray().join(&quot; &quot;));<br>  } catch (e) {<br>    _error(&quot;Exception encountered: &quot; + e);<br>    throw e;<br>  }<br>})();</pre><p>The script logic can be broken down as follows:</p><h4>1. Re<strong>ad in the request parameter of the OAuth2 request</strong></h4><p><a href="https://www.rfc-editor.org/rfc/rfc8707.txt">RFC 8707</a> specifies an additional parameter resource which can be included in the HTTP request to the authorisation server endpoints — e.g.</p><pre>POST /as/token.oauth2 <br><br>grant_type=authorization_code<br>&amp;redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb<br>&amp;code=10esc29BWC2qZB0acc9v8zAv9ltc2pko105tQauZ<br>&amp;<strong>resource=https%3A%2F%2Fcal.example.com%2F</strong></pre><p>The <strong>resource</strong> value is the URL of the resource which the client requires access to — for example a REST API endpoint.</p><p>In our token modification script, we can read this via the requestProperties binding provided with the script environment:</p><pre>    // 1. Read in the request parameter of the OAuth2 request<br>    var requestedAudience = requestProperties.requestParams.get(<br>      OAUTH2_RESOURCE_PARAMETER<br>    );</pre><h4>2.<strong> Validate the resource</strong></h4><p>RFCs 9068 and 8707 do not include any specific requirements for validating the resource requested. For our purposes, we are going to store a list of permitted resource URLs within the OAuth2 client profile stored in ForgeRock.</p><p>We can do this using the custom OAuth2 client property allowedAudiences, containing an array of resource URLs which are permitted for this client.</p><p>The token modification script environment gives access to OAuth2 client properties via the clientProperties binding: we can use this to look up allowedAudiences property and check that it includes the requested audience.</p><pre>    // 2. Validate the resource<br>    _debug(&quot;Requested audience: &quot; + requestedAudience);<br>    var allowedAudiences = JSON.parse(<br>      clientProperties.customProperties.allowedAudiences<br>    );<br>    _debug(&quot;Allowed audiences: &quot; + allowedAudiences);<br>    if (!allowedAudiences.includes(requestedAudience)) {<br>      _error(&quot;Requested audience not permitted: &quot; + requestedAudience);<br>      throw javaImports.InvalidRequestException(<br>        &quot;Requested audience not permitted: &quot; + requestedAudience<br>      );<br>    }</pre><h4>3. Add the client_id claim with the requesting OAuth2 client</h4><p>We can override any claim in the access token via the accessToken binding in the script environment. We use this binding to set the <strong>client_id</strong> claim to the ID of the OAuth2 client making the request:</p><pre>// 3. Add the client_id claim with the requesting OAuth2 client<br>accessToken.setField(&quot;client_id&quot;, clientProperties.clientId);</pre><h4>4. <strong>Override the aud claim with the requested resource</strong></h4><p>Next we set the <strong>aud</strong> claim to the requested (and validated) resource:</p><pre>// 4. Override the aud claim with the requested resource<br>accessToken.setField(&quot;aud&quot;, requestedAudience);</pre><h4>5. <strong>Flatten the scope value</strong></h4><p>Finally, we fix the formatting of the <strong>scope </strong>claim. By default, the ForgeRock platform encodes the <strong>scope</strong> value as a JSON array of scopes — e.g.</p><pre>  &quot;scope&quot;: [<br>    &quot;openid&quot;,<br>    &quot;profile&quot;,<br>    &quot;reademail&quot;<br>  ]</pre><p>In order to comply with RFC9068, we are overriding the value with a flattened version of the scopes — i.e. a single string containing a space separated list of scopes — e.g.</p><pre>&quot;scope&quot;: &quot;openid profile reademail&quot;</pre><p>We do this in the modification script as follows:</p><pre>// 5. Flatten the scope value<br>accessToken.setField(&quot;scope&quot;, accessToken.getScope().toArray().join(&quot; &quot;));</pre><h3>Implementation</h3><p>The required configuration of the ForgeRock platform breaks down into two tasks</p><ul><li>Create the access token modification script</li><li>Configure the OAuth2 provider to use the script, or configure the OAuth2 client specifically</li></ul><p>Regarding the second task, the ForgeRock platform allows you to configure settings at the provider level — i.e. for all OAuth2 clients in a realm — or at the OAuth2 client level through client overrides. For our purposes, we are going to configure at the client level so that we don’t impact any other clients in the realm.</p><h4><strong>1. Create the access token modification script</strong></h4><p>First step is to create a new access token modification script as per the <a href="https://backstage.forgerock.com/docs/idcloud-am/latest/oauth2-guide/plugins-access-token-modifier.html#sample-script">ForgeRock documentation</a>, using the sample script above. In this example, we are going to call the script access-token-mod-rfc-9068</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dm5iu72RwJC_dKv19f43Vg.png" /></figure><h4><strong>2. Configure an OAuth2 client</strong></h4><p>Next step is to <a href="https://backstage.forgerock.com/docs/idcloud/latest/app-management/applications.html">create an OAuth2 client</a>. In this example, we are going to use the following configuration, representing a public client such as a JavaScript single page application (<a href="https://developer.mozilla.org/en-US/docs/Glossary/SPA">SPA</a>).</p><ul><li>Client name: <strong>client9068</strong></li><li>Scopes: <strong>openid photo:read</strong></li><li>Subject type: <strong>public</strong></li><li>Token endpoint authentication method: <strong>none</strong></li></ul><p>Once the OAuth2 client is created, we are going to configure some advanced properties in the client profile. Note that for these properties, we currently need to configure the client via the Access Management Native Console in the ForgeRock platform — this is accessible via the main menu of the platform admin UI.</p><p>Firstly, we add the custom property allowedAudiences with an array of resource URLs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIkOaBphFvc0u3UnltGNdg.png" /><figcaption>OAuth2 Client — Advanced Properties</figcaption></figure><p>Next, we set the OAuth2 provider overrides. First, make sure that the overrides toggle is enabled:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-xeOAT3VaP0f66Av10hZw.png" /><figcaption>OAuth2 Provider Overrides — Enable</figcaption></figure><p>Next, set the overrides to use the access token modification script we created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkE4F2OpnmPs035vVcUXeg.png" /><figcaption>OAuth2 Provider Overrides — Token Modification</figcaption></figure><p>Finally, set the overrides to use client-side access tokens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KuWE4U0Qnc4ty4rQfPDUng.png" /><figcaption>OAuth2 Provider Overrides — Client Side Access Tokens</figcaption></figure><h3>Trying it out</h3><p>We are now ready to try out the new access token profile. To illustrate this, we can retrieve an access token from the ForgeRock OAuth2 token endpoint, using an authorisation code which we have obtained via the standard <a href="https://backstage.forgerock.com/docs/idcloud-am/latest/oauth2-guide/oauth2-authz-grant-pkce.html">authorisation code flow</a>.</p><pre>curl --location &#39;https://openam-xxxxxxxx.forgeblocks.com/am/oauth2/realms/root/realms/alpha/access_token&#39; \<br>--header &#39;Content-Type: application/x-www-form-urlencoded&#39; \<br>--data-urlencode &#39;redirect_uri=https://postman-echo.com/get&#39; \<br>--data-urlencode &#39;grant_type=authorization_code&#39; \<br>--data-urlencode &#39;client_id=client9068&#39; \<br>--data-urlencode &#39;code=X0rzrekjFtrG07zU4CZ0blfTqxM&#39; \<br>--data-urlencode &#39;code_verifier=codeverifier&#39; \<br>--data-urlencode &#39;resource=https://info.idhub.cc/bio&#39;</pre><p>This request includes the <strong>resource</strong> parameter, set to <strong>https://info.idhub.cc/bio</strong>: this URL is included in our OAuth2 client config above as an authorised resource.</p><p>In response, the ForgeRock platform returns an access token with the requested scope and audience:</p><pre>{<br>    &quot;access_token&quot;: &quot;eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5ZWIzYzQyYi1kMjIwLTRiMzctODQ0NC1jNmY5ZTM5ODBkYjciLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiYmU4ZWU1MDEtZDc3Ny00NmRjLTkwOGYtODFhZDhjZTY4ZWQ5LTQ3OTkyMyIsInN1Ym5hbWUiOiI5ZWIzYzQyYi1kMjIwLTRiMzctODQ0NC1jNmY5ZTM5ODBkYjciLCJpc3MiOiJodHRwczovL29wZW5hbS1icmluZGxleS5mb3JnZWJsb2Nrcy5jb206NDQzL2FtL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYWxwaGEiLCJ0b2tlbk5hbWUiOiJhY2Nlc3NfdG9rZW4iLCJ0b2tlbl90eXBlIjoiQmVhcmVyIiwiYXV0aEdyYW50SWQiOiJ4bi1EQjhrNENGazBGRDA5NHdLWlVkWm94dEUiLCJhdWQiOiJodHRwczovL2luZm8uaWRodWIuY2MvYmlvIiwibmJmIjoxNjgyNjAwODUzLCJncmFudF90eXBlIjoiYXV0aG9yaXphdGlvbl9jb2RlIiwic2NvcGUiOiJwaG90bzpyZWFkIiwiYXV0aF90aW1lIjoxNjgyNTk5Nzc5LCJyZWFsbSI6Ii9hbHBoYSIsImV4cCI6MTY4MjYwNDQ1MywiaWF0IjoxNjgyNjAwODUzLCJleHBpcmVzX2luIjozNjAwLCJqdGkiOiJ4Z0Vfa2NMc3lranNEV2pqbFpzOGtZZVlIdkUiLCJjbGllbnRfaWQiOiJjbGllbnQ5MDY4In0.DEGU1YO6u3Rgyea6v8o26f6msiS3X7mX6vnJoFGH1RA&quot;,<br>    &quot;scope&quot;: &quot;photo:read&quot;,<br>    &quot;token_type&quot;: &quot;Bearer&quot;,<br>    &quot;expires_in&quot;: 3599<br>}</pre><p>When we decode this access token, we get the following payload, demonstrating that the token payload complies with the RFC:</p><pre>{<br>  &quot;sub&quot;: &quot;9eb3c42b-d220-4b37-8444-c6f9e3980db7&quot;,<br>  &quot;cts&quot;: &quot;OAUTH2_STATELESS_GRANT&quot;,<br>  &quot;auth_level&quot;: 0,<br>  &quot;auditTrackingId&quot;: &quot;be8ee501-d777-46dc-908f-81ad8ce68ed9-479923&quot;,<br>  &quot;subname&quot;: &quot;9eb3c42b-d220-4b37-8444-c6f9e3980db7&quot;,<br>  &quot;iss&quot;: &quot;https://openam-xxxxxxxxx.forgeblocks.com:443/am/oauth2/realms/root/realms/alpha&quot;,<br>  &quot;tokenName&quot;: &quot;access_token&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;authGrantId&quot;: &quot;xn-DB8k4CFk0FD094wKZUdZoxtE&quot;,<br>  &quot;aud&quot;: &quot;https://info.idhub.cc/bio&quot;,<br>  &quot;nbf&quot;: 1682600853,<br>  &quot;grant_type&quot;: &quot;authorization_code&quot;,<br>  &quot;scope&quot;: &quot;photo:read&quot;,<br>  &quot;auth_time&quot;: 1682599779,<br>  &quot;realm&quot;: &quot;/alpha&quot;,<br>  &quot;exp&quot;: 1682604453,<br>  &quot;iat&quot;: 1682600853,<br>  &quot;expires_in&quot;: 3600,<br>  &quot;jti&quot;: &quot;xgE_kcLsykjsDWjjlZs8kYeYHvE&quot;,<br>  &quot;client_id&quot;: &quot;client9068&quot;<br>}</pre><h3>Conclusion</h3><p>As we have seen, the client side access tokens provided by the ForgeRock platform are largely compliant with RFC 9068 out of the box, being JWT based tokens, backed by standards based issuer endpoints. With a little extra configuration, ForgeRock tokens can be brought into line with the requirements of the RFC, and client level overrides can be used to ensure backwards compatibility for resource servers relying on any other JWT profile.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14c7e25079ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kill the Keyboard: Modern Authentication via SMS]]></title>
            <link>https://medium.com/@christian.brindley/kill-the-keyboard-modern-authentication-via-sms-72e4389be79b?source=rss-53dada6f78f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/72e4389be79b</guid>
            <category><![CDATA[forgerock-identity-cloud]]></category>
            <category><![CDATA[sms]]></category>
            <category><![CDATA[forgerock]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[mfa]]></category>
            <dc:creator><![CDATA[Christian Brindley]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 10:34:17 GMT</pubDate>
            <atom:updated>2023-04-19T10:03:37.360Z</atom:updated>
            <content:encoded><![CDATA[<p>The Short Message Service celebrated its <a href="https://www.bbc.co.uk/news/technology-63825894">30th birthday</a> in 2022. The world of authentication has undergone a lot of changes since 1992, but the humble SMS seems to be here to stay. Despite all the modern techniques we have for identifying, authenticating and authorising people and devices, we are still addicted to SMS as the backstop for multi-factor authentication. It is used across the board, from consumer online banking to corporate VPN access.</p><p>Despite well known drawbacks, both in terms of reliability and security, SMS is simple and ubiquitous, and apparently going nowhere any time soon. In this article, we are going to look at ways in which we can embrace and extend the use of SMS to everyone’s advantage.</p><h3>Fact: people hate typing</h3><p>When going through two step verification, a user is typically asked to look out for a verification SMS, and enter the code they see in the message.</p><p>As humans, we don’t like typing. We want access to the services we are entitled to without constantly having to type user IDs, passwords and one time codes. Even the smallest of inconveniences, like having to remember and type a 6 digit code, introduces friction and undermines the seamless experience we expect in the modern world. This is particularly true where the keyboard is an alien concept to the service being consumed, such as streaming platforms, video conferencing and so on.</p><p>The ideal is to demand no interaction at all during the authentication and authorisation process. Where interaction is required, we should avoid the keyboard as far as possible so as to avoid disrupting the user experience. We should look at ways to tap or click our way through the authentication process with no typing, even when using legacy methods of authentication such as SMS.</p><h3>Tapping beats typing</h3><p>Two ways we can help avoid the keyboard are to use links rather than input fields, and to persist information via browser tools rather than via human memory.</p><p>The easy win is to offer to remember the user ID, and persist this via a cookie. In the case of a password, we could remove it altogether. Let’s face it — if we enforce passwords, a lot of people will be letting their browser remember the password anyway: we often discover this when the login page is changed and suddenly users have to remember their password again.</p><p>We can also persist verification data by profiling the device in use, and storing that device information with the user profile.</p><p>However, no matter how much we store and persist verification data, there will be occasions where we need to perform additional authentication of a user’s identity, and nine times out of ten we will be falling back on SMS or email based verification.</p><p>In the case of email, the traditional approach is to send a one time verification code to the user’s registered email address, which they enter into the login page as part of authentication. For modern platforms, it is increasingly common to use magic links for email based verification.</p><p>The logical progression for SMS is to use a magic link in a similar way to email based verification. This allows us to avoid the awkward process of reading a one time code from a text message and typing the code into a separate device (or worse still, the same device).</p><h3>A richer authentication process</h3><p>As well as delivering a comfortable user experience, links offer a way to enrich the authentication process. By firing up the mobile browser, we can do some interesting things: we can give the user feedback on the authentication context, and perform additional verification behind the scenes to inform the authentication process. For example we can correlate the location of the mobile device with the web session, or look for anomalies in the device context.</p><p>There are caveats to this approach. For example, we cannot rely on data services on the mobile device in use, and not everyone will be comfortable tapping links in SMS messages. The design should therefore include a traditional fallback method such as one time code.</p><h3>What does this look like?</h3><p>There are various ways we could implement this approach. As an example, the following flow for the web channel uses the journey framework of the <a href="https://backstage.forgerock.com/docs/idcloud/latest/home.html">ForgeRock Identity Platform</a>.</p><h4>Access request</h4><p>A user accesses content on their browser which requires login. We prompt them to log in with their email address (which we have remembered from last time to save typing):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f8tYaQF9HnMTYH29xjm1AQ.png" /></figure><p>We could store a cookie in the device to log the user straight at this point. Occasionally however, we may want to expire the cookie to reverify the user’s identity. In this case, we give the option of SMS as a convenient way of completing login (we also offer a different way to log in if this is not going to work for them):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aCkx6ECSZdV85p-XXhytCA.png" /></figure><h4>Acknowledgment via SMS</h4><p>After the user clicks “Send me a text” we show a holding page while we send a link to their registered mobile number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-R6PgXm9LaphOZK2Uie6_g.png" /></figure><p>They receive the message on their mobile device, and tap the unique link in the message to bring up the request details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvahBITENmc1VcvDynZcVA.png" /></figure><p>We can include as much or as little information as we want in the access request details. This gives the user a chance to block the request if it is not expected, and maybe take further action such as locking access or reporting the event.</p><p>As soon as the user taps “Allow” on their mobile device, authentication is complete, and the web session continues as a logged in user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rg9Zc-roe2RNaD63J_v8og.png" /></figure><p>In terms of user experience, this is similar in many ways to push based authentication, where we send a notification to a registered mobile app to complete the authentication process. The advantage here is that we avoid the need for a dedicated app; we are using the traditional SMS channel coupled with the mobile browser (and a fallback OTP in case there is no data access, or any other issues with the mobile browser approach).</p><p>One notable aspect of this approach is that it involves no typing: all we have required from the user is to click a button, tap a link and then tap another button.</p><h3>Caveats</h3><p>As is always the case with authentication, we have to review any design within the broader picture of user context and behaviour, and guard against any potential security or usability issues. Many of these considerations apply to SMS based verification generally, rather than magic links specifically. Some things to look out for are:</p><ul><li><strong>Constrained circumstances</strong>. The user won’t always have their mobile device to hand, and even if they have their mobile with them, they won’t always have data services. The authentication flow needs to provide alternative means of verification under these circumstances.</li><li><strong>Delays in message delivery. </strong>We have no control over how long the message takes to arrive. The holding page should have a timeout, after which we offer alternatives such as continuing to hold or using another means of verification such as email. It is common to have a link or button to resend the SMS; however, the most likely outcome of this option is increased cost and confusion for no real benefit.</li><li><strong>Personal preferences.</strong> Not all users like tapping on links in mobile messages. They may prefer the use of verification codes, or their device may make it difficult or impossible to follow links. In the example above, the holding page has a button to enter the code instead of tapping on the link.</li><li><strong>Nuisance from third parties.</strong> If SMS is the only factor of authentication, then there needs to be some protection against third parties deliberately or accidentally flooding the user with messages by attempting multiple logins with their userid or email address. This can incur significant cost for the service provider. There needs to be some form of throttling — e.g. rate limiting or blocking multiple active requests. Some additional verification may be appropriate, such as device fingerprinting or cookie based verification.</li><li><strong>Impersonation attacks. </strong>A malicious third party may attempt to log in at the same time as the legitimate user, potentially causing the user to acknowledge the wrong request. Again, this can be mitigated by allowing only one active request at a time.</li><li><strong>Fraudulent behaviour. </strong>Malicious actors may attempt to exploit an SMS based verification service by registering premium mobile numbers and collecting the revenue at the service provider’s expense, often labelled International Revenue Share Fraud (<a href="https://www.telesign.com/blog/irsf-fraud">IRSF</a>). This is a symptom of open registration together with SMS based verification journeys. This particular behaviour can be mitigated by checking mobile numbers via a verification service provider such as <a href="https://twilio.com/">Twilio</a>, <a href="https://numverify.com/">Numverify</a> or <a href="https://www.gsma.com/services/irsf_prevention/">GSMA</a>.</li></ul><h3>Conclusion</h3><p>As stated from the outset, SMS based verification is going to be with us for some time yet. We should embrace SMS rather than try to fight its use, look for ways to counter its caveats and blend it with modern techniques rather than simply layering it on top of other factors of authentication.</p><p>SMS based magic links offer value both to the service provider and to the end user. The user gains convenience, undergoing strong authentication via a couple of taps; the service provider gains a happy customer together with deeper insight into user context to help inform authentication decisions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72e4389be79b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>