Welcome to Visier's Embedding Exemplar. This repository is designed to make embedding easy for Visier Partners. With minimal configuration, this repository serves a mock web application that embeds Visier for an analytic tenant. The embedding exemplar is for Visier Partners that have a sandbox tenant and are embedding Visier for the first time or testing tenant single sign-on (SSO) configurations. The exemplar has three key features:
- It contains extensive inline comments documenting each step of the embedding process.
- It is a working application that embeds Visier that can serve as a reference, and little configuration is required. You may choose to copy some code snippets into your own applications.
- The most recent SAML assertion sent to Visier is recorded in
/saml/saml-log.xml
. Use a successful SAML assertion as a guide if you encounter rejected SAML assertions in your own embedding application.
If you intend to use SSO for your own users (as opposed to your customers' users), speak with your Visier Implementation consultant.
To embed Visier, the partner application must include three elements:
- JavaScript code that fetches and bootstraps the Visier SDK as a usable API.
- See
embedded-application.js
- See
- An iframe that will house Visier.
- See
iframe#visier-app
inembed-application.html
.
- See
- A handler for each message type that Visier may post.
- See
embedded-application.js
- See
As an example of how these three components work together to embed Visier, consider the sequence of events that occurs when Visier is successfully embedded in this application for an existing Visier user:
- The JavaScript code fetches and bootstraps the Visier SDK with a
visierConfig
containing thevisierUrl
. - The JavaScript code calls embedApp, passing in the ID for the iframe that will house Visier (here,
#visier-app
). - The API kicks off authenticating in the background on a hidden session iframe. Upon successful authentication, it receives authentication tokens.
- The API sets up a service worker and passes the authentication tokens to it. This service worker intercepts any requests from the embedded app to Visier servers and attaches the tokens as headers. With the headers, the requests can be authenticated properly.
- Optionally, the JavaScript code calls
get("APPLICATION_SECTIONS")
and uses the response to build the navigation bar. Visier is now successfully embedded in the partner application! Be aware that there are other workflows that may take place, such as when an error occurs. Seeembed-application.js
for documentation and implementation of other workflows.
For more detailed documentation on embedding Visier, see https://docs.visier.com/embedded/Visier%20API/integration/embed-visier-home.htm.
The directory hierarchy is structured as follows:
/
app.js
→ Contains the Express server with middleware and endpoints.config.js
→ Must be configured for the sandbox tenant you will embed.
public/
index.html
→ Allows a "user" to log into the "partner" application. The credentials used to log in are picked up by Express middleware and used in the SAML assertion sent to Visier.embed-application.html
andembed-application.js
→ Embed Visier with navigation, auto-provisioning, and error handling.embed-chart.html
→ Embeds selected Visier content in a containing web page.
views/
→ Handlebars templates.form.hbs
→ Renders a form with specified attributes that immediately submits a POST request to a specified URL. It is used primarily by theconnectVisierSession
endpoint to automatically submit a POST request containing a SAML response to Visier from the client.
saml/
visierSession.js
→ Generates a SAML response for the user credentials entered on the sign in page. It depends onsamlp
.visierProfileMapper.js
→ Maps user credentials to SAML claims; Required bysamlp
.saml-log.xml
→ Contains the most recent SAML assertion sent by this application.
bin/
generate-certs.sh
→ Generates the public key infrastructure (PKI) required for generating SAML assertions and serving an HTTPS application. Called formnpm run generate-certs
.www
→ Bootstraps the application. Called fromnpm start
.
certificates/
→ Contains the PKI required to generate SAML assertions and serve an HTTPS application. Generated bynpm run generate-certs
.
yarn install
npm run generate-certs country state city organization_name organization_url
You must configure a URL in this application to values specific for your organization's sandbox tenant. Obtain the vanity URL for your sandbox tenant from your Visier Implementation Consultant. This URL will look similar to https://example.visier.com
. Replace {{vanityName}}
in the following locations:
- In
./config.js
, replace forsaml.visierAcsUrl
- SAML assertions must be sent to this URL to create Visier user sessions.
- In
./public/embed-application.js
and./public/embed-chart.html
, replace forvisierConfig.visierUrl
- Used to load the SDK and authenticate the user.
- Change the value of
hostname
in./config.js
. - Add an entry to your
/etc/hosts
file to direct this hostname to your localhost. For example, 127.0.0.1 www.visier-exemplar.com. - Add an entry to your Visier sandbox tenant's "embeddable domains" (see below) that matches the new hostname.
- In
./public/embed-chart.html
, change thevisierConfig
objects to use your new hostname for theidpUrl
property.
You must add a SSO configuration and embeddable domain to your Visier sandbox tenant.
- In Visier, open the studio experience in your sandbox tenant.
- On the global navigation bar, click
Settings > Tenant Single Sign-On.
- Create an SSO configuration with the following values taken from
config.js
:- Issuer:
saml.samlIssuerUrl
Default ishttps://www.visier-exemplar.com
. - IdP URL:
{{hostname}}/connectVisierSession
Using the default value yieldshttps://127.0.0.1/connectVisierSession
. - Certificate: Set to the value of the file at
saml-cert.pem
. Ensure you have already run thegenerate-certs
script as described above.
- Issuer:
- Navigate back to
Tenant Single Sign-On
. Turn onEnable SSO
and then turn onAuto Provision
.
- In your sandbox tenant, on the global navigation bar, click
Settings > Embeddable Domains
. - Add an entry for the
hostname
specified inconfig.js
(default ishttps://127.0.0.1
).
npm start
The start
script will automatically open a browser tab for the application, but you can also navigate to https://127.0.0.1
if this fails.