DynamicHTTPMetadataProvider fetches entity metadata just-in-time from a remote HTTP server. The metadata request URL is constructed by applying a transform to the
entityID. The transform strategy is configured in a child element.
Metadata is cached in memory subject to a complex set of interacting settings and the cache indicators within the metadata itself, and also can be saved to disk and reloaded back into memory at reload or startup time to restore the state of the cache. This isn't a fully redundant safety net but can be used as part of an overall strategy to reduce the risk of relying on remote sources in real-time. Ultimately, remote sources have to be bulletproof or there will be outages. This can be mitigated but not fully eliminated as a risk.
Use this provider with remote metadata
DynamicHTTPMetadataProvideris used with remote metadata. See the MetadataManagementBestPractices topic for more information.
Schema Names and location
<MetadataProvider> element and the type
DynamicHTTPMetadataProvider are defined by the
urn:mace:shibboleth:2.0:metadata schema, which can be located at http://shibboleth.net/schema/idp/shibboleth-metadata.xsd.
|String||required||Identifier for logging, identification for command line reload, etc.|
|String||required||Specifies the exact type of provider to use (from those listed above, or a custom extension type).|
The following attributes are common to all metadata provider types except the
Whether candidate metadata found by the resolver must be valid in order to be returned (where validity is implementation specific, but in SAML cases generally depends on a
|Boolean||true||Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.|
|Integer||Defines the order in which metadata providers are searched (see below), can only be specified on top level |
|The following are advanced settings supporting a new low-level feature allowing metadata lookup by keys other than the unique entityID and are rarely of use to a deployer.|
|Bean ID||Identifies the a custom |
|Boolean||true||Flag which determines whether the default |
|Boolean||false||Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).|
|Bean ID||shibboleth.ParserPool||Identifies a Spring bean for the XML parser used to parse metadata. Generally should not be changed.|
|Bean ID||Identifies a Spring bean containing a Java |
|Real Number (strictly between 0.0 and 1.0)||0.75||A factor applied to the initially determined refresh time in order to determine the next refresh time (typically to ensure refresh takes place prior to the metadata's expiration). Attempts to refresh metadata will generally begin around the product of this number and the maximum refresh delay.|
|Duration||PT10M (10 minutes)||The minimum duration for which metadata will be cached before it is refreshed.|
|Duration||PT8H (8 hours)||The maximum duration for which metadata will be cached before it is refreshed.|
|Duration||PT8H (8 hours)|
The maximum duration for which metadata will be allowed to be idle (no requests for it) before it is removed from the cache.
|Boolean||true||Flag indicating whether idle metadata should be removed.|
|Duration||PT30M (30 minutes)|
The interval at which the internal cleanup task should run. This task performs background maintenance tasks, such as the removal of expired and idle metadata.
|Bean ID||The optional manager for the persistent cache store for resolved metadata. On metadata provider initialization, data present in the persistent cache will be loaded to memory, effectively restoring the state of the provider as closely as possible to that which existed before the previous shutdown. Each individual cache entry will only be loaded if 1) the entry is still valid as determined by the internal provider logic, and 2) the entry passes the (optional) predicate supplied via |
The directory used for an internally-constructed filesystem-based persistent cache. This is a convenience parameter to avoid specifying a full bean via
|Bean ID||internal default instance||Identifies a Spring bean for a |
|Boolean||true||Flag indicating whether should initialize from the persistent cache in the background. Initializing from the cache in the background will improve IdP startup times.|
|Duration||PT2S (2 seconds)|
The delay after which to schedule the background initialization from the persistent cache when
|Bean ID||an "always true" predicate|
Identifies a Spring bean for an optional
Configuring the Dynamic Attributes
Configure the Dynamic Attributes for the desired cache behavior. In particular, the
minCacheDuration attribute and/or the
maxCacheDuration attribute should be adjusted based on the life cycle of the metadata. Note that the
cacheDuration attribute in metadata (if any) contributes to the overall cache behavior.
The following HTTP attributes are exclusive to the
|Integer||100||The maximum total number of simultaneous connections allowed by the HTTP client's connection pool manager. This attribute is incompatible with |
|Integer||100||The maximum number of simultaneous connections per route allowed by the HTTP client's connection pool manager. This attribute is incompatible with |
|List of String (comma-separated)||"application/samlmetadata+xml, application/xml, text/xml"|
The MIME types supported by this provider when requesting metadata from the HTTP server. The
An HTTP metadata provider includes a default implementation of the
org.apache.http.client.HttpClient interface. The attributes in the following subsections control the behavior of the default HTTP client. To override the default client implementation, configure the following attribute:
A reference to an externally defined Spring bean that specifies an
Use of the
httpClientRef attribute precludes the use of any and all of the HTTP attributes in the following subsections.
HTTP Connection Attributes
The following attributes apply to the HTTP connections obtained and managed by an HTTP metadata provider:
|Duration||Depends on the provider type||The maximum amount of time to wait for a connection to be returned from the HTTP client's connection pool manager. Set to |
|Duration||Depends on the provider type||The maximum amount of time to wait to establish a connection with the remote server. Set to |
|Duration||Depends on the provider type|
|Duration||Depends on the provider type||The maximum amount of time to wait between two consecutive packets while reading from the socket connected to the remote server. Set to |
HTTP Security Attributes
The following security-related attributes apply to any HTTP metadata provider:
If true, no TLS certificate checking will take place over an HTTPS connection. This attribute is incompatible with
|Boolean||false||DEPRECATED: Use |
|Bean ID||A reference to an externally defined Spring bean that specifies an |
HTTP Proxy Attributes
The following attributes configure an HTTP proxy for use with an HTTP metadata provider:
The hostname of the HTTP proxy through which connections will be made. This attribute is incompatible with
The port of the HTTP proxy through which connections will be made. This attribute is incompatible with
The username used with the HTTP proxy through which connections will be made. This attribute is incompatible with
The password used with the HTTP proxy through which connections will be made. This attribute is incompatible with
HTTP Caching Attributes
The following attributes configure an HTTP cache on an HTTP metadata provider:
|Depends on the provider type|
The type of low-level HTTP caching to perform. There are three choices:
This attribute is incompatible with
Some metadata providers, most notably the reloading "batch-oriented" providers, implement HTTP caching at a higher layer and tend to work best with
The maximum number of responses written to cache. This attribute is incompatible with
The maximum response body size that may be cached, in bytes. This attribute is incompatible with
Configuring the HTTP Connection Attributes
DynamicHTTPMetadataProvider, the HTTP Connection Attributes have aggressive default timeout values:
These may be tightened further if desired.
Configuring the HTTP Caching Attributes
By default, a
DynamicHTTPMetadataProvider caches metadata in memory (
httpCaching="memory"). The default values of the HTTP Caching Attributes are optimized for numerous, relatively small metadata files (i.e., single entity descriptors).
A file cache is volatile
Any of the following child elements may be specified, in the specified order (i.e. filters must appear first, then optionally a trust engine, and finally one of the request construction elements.
|0 or more||A metadata filter applied to candidate metadata as it flows through the metadata pipeline|
|0 or 1||A custom |
|0 or 1||Constructs the metadata request URL based on the requirements of the Metadata Query Protocol|
|0 or 1||Constructs the metadata request URL by means of a simple transform based on substitution|
|0 or 1||Constructs the metadata request URL by means of a complex transform based on a regular expression|
> child element is common to all metadata providers while the <> child element is common to all HTTP metadata providers. The remaining child elements are exclusive to the
At most one of the
<Regex> child elements is allowed. If none are configured, the provider constructs the metadata request URL directly from the
entityID. This corresponds to the "well-known location" mechanism defined in the SAML 2.0 Metadata specification, section 4.1.
Don't forget to configure a child element
entityIDto be an URL (not an URN) but the provider does not check the URL scheme. If the scheme on the
entityIDis "http:", the metadata exchange will be vulnerable to a man-in-the-middle attack. For this reason, the well-known location strategy should be avoided in most cases.
<MetadataQueryProtocol> child element
<MetadataQueryProtocol> child element is used, the metadata request URL is constructed according to the SAML Profile for the Metadata Query Protocol, which itself is based on the Metadata Query Protocol specification. The content of the
<MetadataQueryProtocol> child element will be used as the "Base URL" defined in that specification.
<MetadataQueryProtocol> child element has the following optional attribute:
|Bean ID||A reference to a transform function for the |
transformRef attribute may be used if (and only if) the child element is empty (i.e., it has no content).
<Template> child element
<Template> child element is used, the metadata request URL is constructed by means of a simple transform. Specifically, the value of the
entityID is substituted into the template parameter "
<Template> child element has the following attributes:
"none", "form", "path", or "fragment"
Determines whether and how the entityID value will be URL encoded prior to replacement. Allowed values are:
The precise definition of these terms is defined in the documentation for the methods of the Guava library's UrlEscapers class.
|Boolean||true||Deprecated. Use 'encodingStyle instead as of v3.4. If the element contains an |
|Bean ID||A reference to a transform function for the |
|Bean ID||shibboleth.VelocityEngine||This attribute may be used to specify the name of the Velocity engine defined within the application.|
transformRef attribute may be used if (and only if) the child element is empty (i.e., it has no content).
<Regex> child element
<Regex> child element is used, the metadata request URL is constructed by means of a complex transform. The
entityID value is first matched against the regular expression contained in the
match attribute. Then, the
<Regex> element's content is treated as a replacement expression to run based on the results of the match.
<Regex> child element has the following required attribute:
|String||required||A regular expression against which the |
Note that only numeric/positional group references (e.g.,
$1) are supported.
A typical use case is to load entity metadata dynamically from a metadata query server (i.e., a server that supports the Metadata Query Protocol). Here is a complete example:
Note that the
<MetadataQueryProtocol> child element encodes the base URL of the Metadata Query Protocol. For example, consider the following child element:
<MetadataQueryProtocol> child element is equivalent to the following
<Template> child element:
The above configuration explicitly formulates an MDQ protocol URL. This example is for illustration purposes only. If the server supports the Metadata Query Protocol, a
<MetadataQueryProtocol> child element should be used instead. This intentionally hides the details of the Metadata Query Protocol.
Finally, here is an example of the well-known location strategy:
Frequently Asked Questions
What does “dynamic” mean?
DynamicHTTPMetadataProvider fetches entity metadata as needed. We say that the IdP queries for SP metadata just-in-time.
Compare this to a
FileBackedHTTPMetadataProvider that batch loads all of the entity descriptors in a metadata file whether or not the individual entity descriptors are actually needed. In contrast, a
DynamicHTTPMetadataProvider loads exactly those entities that are needed—no more, no less. In this sense, a
DynamicHTTPMetadataProvider is much more efficient.
OTOH, all metadata query protocols are synchronous protocols by definition. Basically the IdP is blocked until it obtains the metadata it needs.
How does metadata query work?
When an IdP receives a SAML protocol request from a particular SP, the IdP must first obtain entity metadata for that SP. If the IdP has no such metadata in its possession, metadata resolution proceeds sequentially according to a configured chain of metadata providers. Upon encountering a
DynamicHTTPMetadataProvider in the chain, the IdP consults an HTTP client that acts as an intermediary between the IdP and the query server.
The HTTP client implements a shared HTTP cache. (RFC 7234) If the desired metadata is already cached, and the stored response is fresh, the client immediately returns the cached metadata to the IdP. Otherwise the client issues an HTTP request to the query server. Upon receiving a response from the server, the client caches the response and finally returns the metadata to the IdP.
In either case, the IdP parses the metadata and applies any metadata filters configured on the
DynamicHTTPMetadataProvider. The metadata that ultimately emerges from the configured metadata pipeline is cached locally (in memory) for future use.
The next time the IdP receives a SAML protocol request from this SP, it again traverses the chain of providers until it encounters the
DynamicHTTPMetadataProvider. This time, however, the IdP does not bother to consult the HTTP client since the needed metadata is in the IdP’s local cache.
How long does the metadata remain in the IdP’s local cache?
The IdP’s local cache is governed by the Dynamic Attributes. In particular, the
maxCacheDuration attributes strongly influence the life cycle of metadata in the local cache. Any
validUntil attributes in the metadata itself also influence the behavior of the local cache.
Does the HTTP client cache the response in memory?
Yes, by default the HTTP client caches responses in memory (
httpCaching=”memory”). Consequently, two copies of each entity descriptor reside in memory, one managed by the HTTP client and another one managed directly by the IdP.
The HTTP client may be configured for file caching but a file cache will not survive a restart so the overall benefit of file caching is reduced. In most cases, a memory cache is preferred, at least for systems with adequate memory,
Does the HTTP client support HTTP conditional GET?
Yes, the HTTP client supports HTTP conditional GET (RFC 7232) for optimal performance but the inner workings of the HTTP client are opaque to the IdP. If the IdP does in fact consult the HTTP client, and the client returns metadata to the IdP, the IdP blindly parses the metadata and applies the metadata filters. There are no optimizations implemented on the IdP side.
What if the metadata query server is down or unavailable?
When the HTTP client sends an HTTP request to a metadata query server, the SAML protocol exchange is blocked until a response is received from the server and returned to the IdP. If the client reports a failed request, the IdP continues with the next provider in the configured chain of providers. If the offending
DynamicHTTPMetadataProvider is the last provider in the chain, metadata resolution fails.
What can I do to minimize the impact of metadata query?
There are at least three things you can do to help minimize the impact of metadata query:
Configure the HTTP Connection Attributes
Configure a robust chain of metadata providers
As noted above, the
maxCacheDuration attributes strongly influence the life cycle of metadata in the local cache. The goal is to avoid needless interaction with the HTTP server. To achieve this goal, you need to understand the life cycle of the metadata on the server. For this reason, it is best to ask your federation operator for specific recommendations.
OTOH, the federation operator may influence the life cycle of metadata in the IdP’s local cache by including a
cacheDuration attribute in the metadata itself. In that case, the deployer has fewer configuration options to consider, by design.
The HTTP Connection Attributes include the following attributes:
PT5S): The maximum amount of time to wait for a connection to be returned from the HTTP client's connection pool manager.
PT5S): The maximum amount of time to wait to establish a connection with the remote server.
PT5S): The maximum amount of time to wait between two consecutive packets while reading from the socket connected to the remote server.
As noted above, each of these attributes defaults to 5 seconds. You may want to tighten these timeout values further, depending on what you know about the route to the server or the server itself.
Regardless of the IdP configuration or the service-level agreement you have with the server operator, things will go wrong. One thing you can do to hedge your bets is to deploy a local query server as backup. Alternatively, one or more high-value SPs can be pre-loaded into memory.