Filter procedures

Filter procedures can be used to filter items from collections. The type of the filter-procedure determines on what kind of items the filter can be applied on.

A filter procedure has the following structure:

Listing 260 Structure of filter procedure
1
2
3
4
function result(filterContext) {
  // use the context to get the item information and access to other useful facilities
  return true; // return true to keep the item, false to remove it
}

Important

The main function of a filter procedure must be called result.

Function

The result function takes one argument, which is the context of the filter. The type of the context depends on the type of the filter-procedure.

result(filterContext)

The main function of a filter procedure

Arguments:
  • filterContext – The provider context to operate on.
Returns:

a boolean where true means keep the current item, false means exclude the current item.

API

The following filter-procedure types are supported:

Examples of filter procedures can be found in the $INSTALL_DIR/examples/configs/filter-procedures directory.

Authenticator filter-procedure API

Filter procedures of type authenticator can be used in Service Providers and OAuth Client Configuration to filter authenticators.

This type of filter-procedure must have a result function which receives a context as described below:

Authenticator

authenticatorMap

A map data object describing the authenticator that should be decided if it should be filtered out or not.

  • id: The ID of the authenticator.
  • default: whether this is the default authenticator.
  • acr: ACR of the authenticator.
  • description: A description of the authenticator.
  • url: The URL of the authenticator.
  • type: The type of the authenticator.

Context

filterContext
  • authenticator: The current authenticatorMap being filtered.
  • request: The current request Object.
  • accountAttributes: an optional Object containing the currently-authenticated user account attributes. This will be null if the user has not been authenticated yet.
  • originalQueryParameters: A collection containing the query parameters used in the initial request to either the authorization endpoint, or the authentication endpoint
filterContext.accountAttributes

Get an Attributes object with the current account.

Returns:A accountAttributes object
filterContext.authenticator

Get the authenticator to make filter decision on.

Returns:An authenticatorMap object.
filterContext.getAttributeDataSource(dataSourceId)

Retrieves a configured data source with the provided ID if it exists, or null otherwise.

Arguments:
  • dataSourceId (string) – The ID of the data source.
Returns:

A dataSource with the requested ID, or null if it does not exist.

filterContext.request

Returns the httpRequest for the current transaction

Returns:httpRequest for the current transaction
filterContext.response

Returns the httpResponse for the current transaction

Returns:httpResponse for the current transaction
filterContext.response

Returns the originalQueryParameters for the initial request

Returns:originalQueryParameters for the initial request