Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • shibboleth.CSPDigester – this is a StringDigester (that is a Function, with apply() called with a Javascript string as input) and produces a base64-encoded SHA-256 digest suitable for use in CSP’s unsafe-hashes “source expression”.

  • shibboleth.CSPNonceGenerator – this is an IdentifierGenerationStrategy (an interface in our API) whose generateIdentifier() method will produce an adequately random value to use as a nonce.

Hash Example in Velocity

Hashes are the “strongest” rule possible because they specifically allow a single script that hashes to the matching value. They work well when the content of the script is maintained within a view, and in particular for simple one-liner event handlers for onLoad or onClick events. It is a simple matter (and is demonstrated in the new default views in various places) to assign a Javascript string to a Velocity variable, and apply the digester to produce the hash needed to generate the header.

...

As the example shows, changing the script in some way would only require changing the text in the #set macro, because the hash is computed against whatever is found in that variable. Later on the variable would be used to embed the script into the desired spot in the template.

Nonce Example in Velocity

When hashes are too unwieldy to use, nonces are usually the best fallback, and work well for scripts, particularly external ones. Nonces are generated and then added to both a header at the top of a view and in a nonce attribute in the <script> element:

...

Expand
titleProperties

Name

Type

Default

Description

idp.views

Comma-delimited path

%{idp.home}/views

Location of user-supplied views for the resolution process

idp.views.velocity.activationCondition 5.1

Predicate<String>

shibboleth.Conditions.TRUE

Bean ID of a Predicate<String> which determines whether to resolve a view using Velocity or not (the parameter is the view name)

idp.views.velocity.order 5.1

Integer

210

Relative order of the Velocity view resolver

idp.views.jsp.order 5.1

Integer

320

Relative order of the “internal” JSP/JSTL view resolver