Add BDK to an Extension App for Circle of Trust
Last updated
Last updated
Complete the previous guide on building an extension app with app views
Complete the first part of this guide with the assistance of your pod administrator, ensuring that your app has the Primary User Identity and Trust application permissions.
This guide will use a shared extension app entry that is available for everyone to use on the developer sandbox. The app id is localhost-4000
and the RSA private key can be downloaded from this location. This entry expects that the app is hosted on https://localhost:4000
with the entrypoint controller.html
at the root.
In order to obtain identity information of the current user, an extension app needs to perform an authentication call and validation loop as part of the Circle of Trust process. This requires a backend service to call Symphony REST APIs so as to secure the required private key. You can choose to manually create your own REST API client and link the endpoint contracts to the ADK configuration, but this guide will demonstrate how to use BDK to ease the process.
As we won't be using the bot components, we can remove configuration relating to bots. We will also remove the TLS configuration as we will use ADK to host the frontend app instead. We also need to expand the CORS configuration as our frontend will make a cross-origin call to this backend in development mode (modify as appropriately for production).
If you are using your own extension app id and key, change the values as appropriate. If you are using the developer sandbox, download this key into rsa/privatekey.pem
.
Either launch the BDK project from your IDE or use the respective maven or gradle command:
Modify the index.js
or index.ts
file from the earlier ADK project to be as follows:
Note that we previously only supplied id
to the ADK.start
call but we now supply an additioinal circleOfTrust
object in that configuration. This object has 3 properties that each return a promise.
getAppToken
: calls the backend to perform app authentication and retrieve the token
validateAppToken
: calls the backend to perform token validation
validateJwt
: calls the backend to perform JWT validation
ADK takes care of adherence to the Circle of Trust process so you only need to define these contracts to allow ADK to perform the required backend calls.
Now that the app is authenticated, we can fetch user identity from either the controller or views. Let's edit the existing view to be as follows:
We can now start the app using:
Instead of performing bundle injection as before, load Symphony normally now. Once Symphony is loaded, open the Marketplace using the left rail. Locate your App and install it. If you are using the developer sandbox, the app's name is Localhost 4000.
Once the app is installed, you should notice a new app appears in the Apps section labelled as My App. If you launch the app, it opens a module showing the view, which contains your display name and email.