Configure Content Security Policy
PingOne Advanced Identity Cloud lets you configure CSP to restrict access to resources used by your tenant environments or to restrict your tenant environment as a resource used by other websites. You can configure CSP to allow hosted pages to be embedded in your website, to allow hosted pages to use a script from an external domain, or to report policy violations to the browser console or a monitoring service. Advanced Identity Cloud also gives you the flexibility to configure CSP for your own use cases.
CSP configuration is dynamic, so you need to configure it separately in each of your environments. You configure it using the UI, which lets you select policy directives to build an enforced policy, a report-only policy, or both. After you have configured your policies or made policy changes, you can apply them to your environment. Policies apply to both realms.
Default policies
Configure CSP using the UI
-
In the Advanced Identity Cloud admin UI, open the TENANT menu (upper right), then go to Tenant Settings > Global Settings > Content Security Policy.
-
Click the Enforced Policy tab or the Report Only Policy tab to choose the policy type you want to configure.
-
Review any existing policy directives:
-
To edit a directive:
-
Click its ellipsis icon (), then click Edit.
-
In the Directive Sources modal, use the available fields to reconfigure the directive. The available fields vary according to the specification of the directive:
-
Learn more about the available fields for a particular directive in Directives.
-
Learn more about the meaning of directive values in Values.
-
-
Click Save.
-
-
To delete a directive:
-
Click its ellipsis icon (), then click Delete.
-
In the Delete Directive? modal, click Delete.
-
-
-
To add a new policy directive:
-
Click + Add Directive.
-
In the Add Directive modal, select a directive from the list. The list does not show existing directives.
-
In the Directive Sources modal, use the available fields to configure the directive. The available fields vary according to the specification of the directive:
-
Learn more about the available fields for a particular directive in Directives.
-
Learn more about the meaning of directive values in Values.
-
-
Click Save.
-
-
Repeat step 4 until you have added all the policy directives you require.
-
If the policy status is Inactive, click Activate.
-
Click Publish to apply the policy to your tenant environment in both realms. The Publish button appears in a banner at the top of the Content Security Policy page as soon as you make any changes.
CSP use cases
Configure CSP to allow hosted pages in iframes
By default, Advanced Identity Cloud hosted pages cannot be embedded in a website unless both hosted pages and website are on the same domain. This prevents a bad actor from simply embedding your hosted pages login screen in their website and stealing end-user credentials.
To permit a parent website to embed Advanced Identity Cloud hosted pages in an iframe, use the frame-ancestors
policy directive and specify the domain of a valid parent website (or a comma-separated list of
domains if there is more than one valid parent website):
-
For your report-only policy:
-
Use the instructions in Configure CSP using the UI to add or update the
frame-ancestors
policy directive:Content-Security-Policy-Report-Only: ... frame-ancestors 'self' <domain>(1)
1 Replace <domain>
with the domain of the valid parent website; for example,id.mycompany.com
. -
Test the parent website and check the browser console to ensure there are no report-only policy violations for the
frame-ancestors
policy directive.
-
-
For your enforced policy:
Use the same approach as in step 1a and step 1b to add of update the following policy directive:
Content-Security-Policy: ... frame-ancestors 'self' <domain>;
Configure CSP to let hosted pages use a script from an external domain
By default, you cannot use a script in Advanced Identity Cloud hosted pages unless both script and hosted pages are on the same domain.
To permit a script from an external domain in Advanced Identity Cloud hosted pages, use the script-src
policy
directive and specify the domain of a valid source website (or a comma-separated list of domains):
-
For your report-only policy:
-
Use the instructions in Configure CSP using the UI to add or update the
script-src
policy directive:Content-Security-Policy-Report-Only: ... script-src: 'self' <domain>(1)
1 Replace <domain>
with the domain of the valid source website; for example,cdn.cookielaw.org
. -
Test hosted pages and check the browser console to ensure there are no report-only policy violations for the
script-src
policy directive.
-
-
For your enforced policy:
Use the same approach as in step 1a and step 1b to add of update the following policy directive:
Content-Security-Policy: ... script-src 'self' <domain>;
Configure CSP to report to a monitoring service
By default, CSP policy violations are logged to the browser console so are contained to each
end user’s computer or device. To configure policy violations for all end users to be logged to a
monitoring service, add the report-uri
policy directive and specify an endpoint set up to
receive CSP policy violation JSON payloads. The following example configures the CSP report
monitoring service provided by Report URI
to monitor report-only policy violations:
Content-Security-Policy-Report-Only: ... report-uri https://<subdomain>.report-uri.com/r/d/csp/reportOnly;
The following example uses the same approach to monitor enforced policy violations:
Content-Security-Policy: ... report-uri https://<subdomain>.report-uri.com/r/d/csp/enforce;