Skip to content

Commit bc94a3e

Browse files
steverenjeff-allen-mongo
authored andcommitted
DOCSP-4666: [Charts] As a dashboard author, I can enable or disable Signed Auth for a chart (#153)
* DOCSP-4666: [Charts] As a dashboard author, I can enable or disable Signed Auth for a chart
1 parent e171041 commit bc94a3e

File tree

8 files changed

+211
-0
lines changed

8 files changed

+211
-0
lines changed

source/build-charts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ To build a new chart:
3333
/sort-limit-data
3434
/customize-charts
3535
/sample-mode
36+
/embedding-charts

source/data-sources.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ source that the chart uses.
2020
To view, add, or remove data sources, click :guilabel:`Data Sources` on
2121
the top navigation bar.
2222

23+
.. _data-sources-view:
24+
2325
Data Sources View
2426
-----------------
2527

@@ -201,6 +203,59 @@ To remove a data source:
201203
Any charts using the deleted data source will need to be
202204
reconfigured using a different data source or deleted.
203205

206+
.. _data-source-embedding:
207+
208+
Enable or Disable Embedding
209+
---------------------------
210+
211+
As a data source ``Owner``, you can allow other people to
212+
:ref:`embed charts <embedding-charts>` which use your data source
213+
in external web pages. In order to allow a chart to be embedded
214+
in an external web page, you must enable embedding both on the
215+
data source and the individual chart.
216+
217+
Embedding is disabled by default for all data sources. To enable
218+
embedding for a data source:
219+
220+
1. Navigate to your :ref:`Data Sources View <data-sources-view>` page.
221+
222+
#. Click the ellipsis (:guilabel:`...`) button on the far right side
223+
of the desired data source.
224+
225+
#. Select :guilabel:`Embedding Options` from the dropdown menu.
226+
227+
#. Toggle the switch in the top right corner to :guilabel:`On`.
228+
229+
#. Select either:
230+
231+
a. :guilabel:`Verified Signature only`. This option requires
232+
embedded charts to include a :ref:`secret embedding key
233+
<verified-signature>` with each request sent to the data source.
234+
Without a verified signature, the chart will not render. This
235+
option allows the chart owner to ensure that the chart is used
236+
only in its intended context.
237+
238+
Generating a verified signature for authorized users to include
239+
with their embedded charts requires some server-side code.
240+
Examples in several languages and platforms are available with
241+
the :ref:`verified signature documentation <verified-signature>`.
242+
243+
#. :guilabel:`Unauthenticated or Verified Signature`. This option
244+
allows the chart to be viewed either with or without a verified
245+
signature, so that anyone with the link may view the embedded
246+
chart. It is simpler to implement than the verified signature
247+
only option, but it is less secure. It should only be used for
248+
charts which display non-sensitive data.
249+
250+
After enabling embedding for a data source, you can enable embedding
251+
for individual charts which use that data source.
252+
253+
.. note::
254+
255+
If you change the embedding option for a data source from
256+
:guilabel:`On` to :guilabel:`Off`, all embedded charts which use
257+
that data source will stop rendering immediately.
258+
204259
.. class:: hidden
205260

206261
.. toctree::

source/embedding-charts.txt

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
.. _embedding-charts:
2+
3+
========================================
4+
Embedding Charts in Your Web Application
5+
========================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Overview
16+
--------
17+
18+
As a dashboard Author, you can embed charts into your own web sites,
19+
allowing people who are not Charts users to see your visualizations.
20+
You can either require a verified signature to accompany each data
21+
request, or allow anyone with the chart's identifying information to
22+
embed it in a web page.
23+
24+
If you want strict control over who can embed your charts, use the
25+
:ref:`Verified Signature <require-authentication>` option. If your data
26+
is non-sensitive and you prefer a simpler embedding solution, use the
27+
:ref:`Unauthenticated Access <allow-unauthenticated>` option.
28+
29+
.. _embedding-procedure:
30+
31+
Procedure
32+
---------
33+
34+
From your dashboard tab, select the dashboard containing the chart you
35+
wish to make embeddable. From the dashboard, click the ellipsis
36+
(:guilabel:`...`) button at the top-right of the chart to access its
37+
embedding information. Select :guilabel:`Embed Chart` from the dropdown
38+
menu.
39+
40+
If you have not already enabled embedding for the data source this
41+
uses, and if you are the data source owner, you have the opportunity to
42+
do so now. Click the :guilabel:`Enable embedding options` link.
43+
44+
.. figure:: /images/charts/embed-chart-options.png
45+
:figwidth: 507px
46+
:alt: Embed a chart
47+
48+
Once the data source has embedding enabled, you can choose to allow
49+
unauthenticated access or restrict access to those with a
50+
:ref:`verified signature <require-authentication>`.
51+
52+
.. figure:: /images/charts/embed-chart.png
53+
:figwidth: 507px
54+
:alt: Embed a chart
55+
56+
.. _allow-unauthenticated:
57+
58+
Allow Unauthenticated Access
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
To allow anyone with the chart link to embed the chart in a web page,
62+
select the :guilabel:`Unauthenticated` tab and toggle the switch marked
63+
:guilabel:`Enable unauthenticated access` to :guilabel:`On`. The HTML
64+
code necessary to embed the chart appears in the modal window. This
65+
HTML snippet is ready to copy and paste into an external web page.
66+
67+
.. figure:: /images/charts/embed-chart2.png
68+
:figwidth: 508px
69+
:alt: Embed unauthenticated chart
70+
71+
.. _require-authentication:
72+
73+
Require Authentication for Access
74+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75+
76+
For increased security, you can require a verified signature to
77+
accompany each data request for an embedded chart. Select the
78+
:guilabel:`Verified Signature` tab and toggle the :guilabel:`Enable
79+
signed authentication acces` switch to :guilabel:`On`.
80+
81+
.. figure:: /images/charts/embed-chart3.png
82+
:figwidth: 508px
83+
:alt: Embed authenticated chart
84+
85+
In addition to the HTML iframe, the verified signature option requires
86+
some server-side code in order to work. The HTML snippet above shows
87+
what the iframe needs to look like, but it is not usable as-is.
88+
Your web application must use a secret embedding key to sign the URL
89+
and include a timestamp.
90+
91+
.. _verified-signature:
92+
93+
Verified Signature Generation
94+
-----------------------------
95+
96+
To grant data access for embedded charts which require authentication,
97+
you must obtain an embedding key from the :guilabel:`Admin Settings`
98+
page.
99+
100+
.. note::
101+
102+
You must be a :ref:`Project Owner <dashboard-permissions>` to access
103+
the :guilabel:`Admin Settings` page. For users with the
104+
:ref:`Project Owner <dashboard-permissions>` role, the
105+
:guilabel:`Admin Settings` link appears in the top right corner of
106+
the charts UI. As a non-admin user, you can still use embedded
107+
charts, but you will need to ask a Project Owner for a key.
108+
109+
Once you have a key, you can create the server-side code required to
110+
generate the verified signature which must accompany a data request
111+
from an embedded chart. Code examples of how to generate a verified
112+
signature are available for the following languages and platforms:
113+
114+
- `Node.js <https://github.com/mongodb/charts-embedding-examples/tree/master/node>`__
115+
- `C# <https://github.com/mongodb/charts-embedding-examples/tree/master/c-sharp>`__
116+
- `Java <https://github.com/mongodb/charts-embedding-examples/tree/master/java>`__
117+
- `Python <https://github.com/mongodb/charts-embedding-examples/tree/master/python>`__
118+
- `MongoDB Stitch <https://github.com/mongodb/charts-embedding-examples/tree/master/stitch>`__
119+
120+
Embedded Charts Error Codes
121+
---------------------------
122+
123+
If an embedded chart fails to render, an error code is displayed:
124+
125+
.. list-table::
126+
:header-rows: 1
127+
:widths: 20 80
128+
129+
* - Error Code
130+
- Error Cause
131+
132+
* - ``-1``
133+
- Unknown error.
134+
135+
* - ``1``
136+
- Invalid tenant ID. Check the ``tenant`` field in the iframe
137+
HTML and make sure it matches what you see in the
138+
:ref:`Embed Chart <embedding-procedure>` modal window.
139+
140+
* - ``2``
141+
- Item not found. Check the ``id`` field in the iframe
142+
HTML and make sure it matches what you see in the
143+
:ref:`Embed Chart <embedding-procedure>` modal window.
144+
145+
* - ``3``
146+
- Embedding not enabled. Check the settings in your chart's
147+
:ref:`Embed Chart <embedding-procedure>` modal window.
148+
149+
* - ``4``
150+
- Embedding not allowed. Check the embedding settings in your
151+
chart's :ref:`data source <data-source-embedding>`.
152+
153+
* - ``5``
154+
- Invalid payload. Your application server is not creating a
155+
usable :ref:`signature <verified-signature>`.
41 KB
Loading
32 KB
Loading
64.1 KB
Loading
88.4 KB
Loading
303 KB
Loading

0 commit comments

Comments
 (0)