This documentation has been revised for V3.2.0, so take care when applying it to older versions.
File(s): conf/global.xml, conf/idp.properties
Format: Native Spring
The IdP provides a number of general-purpose storage facilities that can be used by core subsystems like session management and consent. Broadly speaking, there are two kinds of storage plugins: client-side and server-side. Client-side plugins have the advantage of requiring no additional software or configuration and make clustering very robust and simple, but they only support a subset of use cases. Server-side plugins (aside from the simple case of storing data in memory) support all use cases, but require additional software and configuration, and usually create additional points of failure in a clustered deployment.
The IdP ships with 3 preconfigured org.opensaml.storage.StorageService beans:
- shibboleth.ClientSessionStorageService (of type ClientStorageService)
- Stores data in a browser session cookie or HTML local storage3.2
- shibboleth.ClientPersistentStorageService (of type ClientStorageService)
- Stores data in a long-lived browser cookie or HTML local storage3.2
- shibboleth.StorageService (of type MemoryStorageService)
- Stores data in server memory, does not survive restarts and is not replicated across a cluster
There are additional storage service plugins included in the software (JPA, memcached) but they are not predefined. Using them requires defining beans yourself and setting various properties to point to them.
By default, the shibboleth.ClientSessionStorageService bean, which stores data in the client, is used to store IdP session data, but that can be modified via the idp.properties file:
There are additional properties that can be used to change how other data is stored on a per-use case basis, but note that some components can't rely on client-side storage options.
The following beans (most of which are internal to the system) can be used in various properties to control what storage instances are used for specific purposes. You can define your own beans also (e.g. in global.xml).
|shibboleth.StorageService||Default server-side storage, stores data in memory|
|shibboleth.ClientSessionStorageService||ClientStorageService||Default client-side storage for per-session data, stores data in session cookies or HTML local storage 3.2|
|shibboleth.ClientPersistentStorageService||ClientStorageService||Default client-side storage for long-lived data, stores data in persistent cookies or HTML local storage 3.2|
|shibboleth.ClientStorageServices||List<StorageService>||Enumeration of ClientStorageService plugins used, ensures proper load/save of data|
|idp.cookie.secure||Boolean||false||Whether cookies created by the software include the "secure" attribute; the default is mostly an accident, you should strongly consider setting this|
|idp.cookie.domain||String||Optional domain to attach to cookies|
|idp.cookie.path||String||Optional path to attach to cookies|
|idp.cookie.maxAge||Integer||31536000||Lifetime of non-session cookies|
|idp.storage.cleanupInterval||Duration||PT10M||Interval of background thread sweeping server-side storage for expired records|
|idp.storage.htmlLocalStorage||Boolean||false||Whether to use HTML Local Storage (if available) instead of cookies|
|idp.storage.clientSessionStorageName 3.3||String||shib_idp_session_ss||Name of cookie or HTML storage key used by the default per-session instance of the client storage service|
|idp.storage.clientPersistentStorageName 3.3||String||shib_idp_persistent_ss||Name of cookie or HTML storage key used by the default persistent instance of the client storage service|
|idp.session.StorageService||Bean ID of a StorageService||shibboleth.ClientSessionStorageService||Storage back-end to use for IdP sessions, authentication results, and optionally tracking of SP usage for logout|
|idp.consent.StorageService||Bean ID of a StorageService||shibboleth.ClientPersistentStorageService||Storage back-end to use for consent and terms-of-use records|
|idp.replayCache.StorageService||Bean ID of a StorageService||shibboleth.StorageService||Storage back-end to use for message replay checking (must be server-side)|
|idp.replayCache.strict 3.4||Boolean||true||Whether storage errors during replay checks should be treated as a replay|
|idp.artifact.StorageService||Bean ID of a StorageService||shibboleth.StorageService||Storage back-end to use for short-lived SAML Artifact mappings (must be server-side)|
|idp.cas.StorageService||Bean ID of a StorageService||shibboleth.StorageService||Storage back-end to use for CAS ticket mappings (must be server-side)|
Versions of the IdP prior to V3.2.0 included a cookie-backed storage plugin used by default for IdP sessions and authentication results. A drop-in replacement for this plugin is used in subsequent versions that includes support for HTML Local Storage along with cookies if the client supports that feature. The new plugin is functionally quite different in its behavior but no configuration changes are required to use it, apart from the decision to enable the Local Storage feature.
There actually is one configuration change you can make: the original deployment descriptor in webapp/WEB-INF/web.xml contains a servlet filter declaration that supported the old cookie-based storage plugin. That filter has been stubbed out in the new version so if you want to gain some infinitesimal efficiency gains, you can copy the file to your edit-webapp tree, remove the following markup, and rebuild the warfile:
Enabling this feature is very simple: just set the idp.storage.htmlLocalStorage property to true.
Much of that look is obviously controlled by style sheets and message properties, but the "visible" portions have been moved into views/client-storage as of V3.3 (to avoid losing your changes on upgrades).
Note that this feature is safe to enable globally. The implementation is written to check for this capability in each client, and to back off to cookies.
As to why you would do this, there are really two main reasons:
The consent feature is very limited when cookies are used because the number of records it can store is extremely small. If Local Storage is available, that limit is essentially ignored. If you're comfortable with tracking consent per-device, this is a much more practical way to deploy it at most sites than with a database. Of course, many deployers are not comfortable with per-device consent.
The main reason for this feature is that by default, the IdP's session manager is configured not to track or index the sessions created with SPs, because that information also does not fit reliably in a cookie. That makes the single-logout feature unusable since the IdP doesn't know what SPs to communicate with. Turning on the Local Storage feature is necessary but not sufficient to allow at least some form of single logout to work without moving session storage to the server. You also will need to enable a couple of additional session management properties (idp.session.trackSPSessions and idp.session.secondaryServiceIndex). There are two properties because the latter is more a SAML-specific need that may not extend to other protocols in the future.
In order to configure this service you must provide Spring bean configuration for the JPAStorageService that includes the driver, URL, and credentials for your database. You are required to provide a jar containing the driver for your particular database. In addition, we recommend the use of a DataSource that provides connection pooling, which may require installing an additional library as well.
The following libraries provide connection pooling functionality:
In the DB-specific examples below use of HikariCP is demonstrated (
class="com.zaxxer.hikari.HikariDataSource", p:jdbcUrl="..." in the DataSource bean). When using other Connection Pool implementations change the class and properties appropriately, e.g.:
- Tomcat DBCP2:
- Tomcat JDBC Pool:
Place the driver jar and connection pooling jar in edit-webapp/WEB-INF/lib then execute bin/build.sh or bin/build.bat as appropriate for your environment.
The following configuration should be placed in conf/global.xml:
The LocalContainerEntityManagerFactoryBean contains more configuration options and is designed to eliminate the need for a persistence.xml file. If you need to alter the database schema you can deploy a custom mapping file which overrides column names and types.
Place your custom orm.xml file in edit-webapp/WEB-INF/classes/META-INF/orm.xml then rebuild your war. While you can configure a custom name and path for this file it must be located on your web application classpath. File system paths are not supported.
Postgres LOB Concerns
Switch identified an issue with the Postgres JDBC driver and the storage of LOBs related to the default mapping. Deployers can experience data loss when the Postgres vacuumlo command is run. It is recommend that a custom orm.xml file be used to override the value type:
See the Switch Installation Docs for more details.
Requirements: memcached v1.4.14 or later
The memcached-based storage facility in IdPv3 is based on the spymemcached library, which has a number of compelling features for HA deployments:
- Optimized IO for high throughput
- Memcached failover facility
- Stable hashing algorithm supports memcached pool resizing
The failover facility merits further discussion. Failover is enabled by specifying multiple memcached hosts and
failureMode="Redistribute". When the client encounters an unreachable host in redistribute mode, it will temporarily remove the unavailable host from the pool of available hosts. Any keys that hash to the unavailable host will be written or retrieved from a backup host. The high-level effect of this behavior on the IdP session management service is that a node failure will cause loss of IdP session, which would impact users as an unexpected authentication. The IdP session management service, however, would be fully functional during a host failure/recovery event. Also note that this behavior requires no state sharing (i.e. repcache) between memcached nodes.
Bear in mind that different storage use cases have different failover properties. While the replay cache would be similarly unimpacted, the artifact map failing to retrieve a previously stored artifact mapping would result in a failed login to the service to which the artifact was sent.
The following architecture is strongly recommended for HA deployments:
Thus every IdP node runs a memcached service and the Java process running the IdP software connects to every memcached service. The following configuration example assumes the recommended architecture above and should be placed in conf/global.xml .
Once a MemcachedStorageService bean has been defined as above, it can be used with subsystems that require a StorageService component. The following configuration snippet from conf/idp.properties indicates how to use memcached for session storage.