Available in stable development 1.14 1.13 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.5

Authentication Processing Filters in SimpleSAMLphp

Table of Contents

In SimpleSAMLphp, there is an API where you can do stuff at the IdP after authentication is complete, and just before you are sent back to the SP. The same API is available on the SP, after you have received a successful Authentication Response from the IdP and before you are sent back to the SP application.

Authentication processing filters postprocess authentication information received from authentication sources. It is possible to use this for additional authentication checks, requesting the user's consent before delivering attributes about the user, modifying the user's attributes, and other things which should be performed before returning the user to the service provider he came from.

Examples of neat things to do using Authentication Processing Filters:

Be aware that Authentication Proccessing Filters do replace some of the preivous features in SimpleSAMLphp, named:

Later in this document, we will desribe in detail the alternative Authentication Proccessing Filters that will replicate these functionalities.

1 How to configure Auth Proc Filters

Auth Proc Filters can be set globally, or to be specific for only one SP or one IdP. That means there are five locations where you can configure Auth Proc Filters:

The configuration of Auth Proc Filters is a list of filters with priority as index. Here is an example of Auth Proc Filters configured in config.php:

'authproc.idp' => array(
    10 => array(
        'class' => 'core:AttributeMap', 
        'addurnprefix'
    ),
    20 => 'core:TargetedID',
    40 => 'core:AttributeRealm',
    50 => 'core:AttributeLimit',
    90 => array(
        'class'     => 'consent:Consent', 
        'store'     => 'consent:Cookie', 
        'focus'     => 'yes', 
        'checked'   => TRUE
    ),
),

This configuration will execute Auth Proc Filters one by one, with the priority value in increasing order. When Auth Proc Filters is configured in multiple places, in example both globally, in the hosted IdP and remote SP metadata, then the list is interleaved sorted by priority.

The most important parameter of each item on the list is the class of the Auth Proc Filter. The syntax of the class is modulename:classname. As an example the class definition core:AttributeLimit will be expanded to look for the class sspmod_core_Auth_Process_AttributeLimit. The location of this class file must then be: modules/core/lib/Auth/Process/AttributeLimit.php.

You will see that a bunch of useful filters is included in the core module. In addition the consent module that is included in the SimpleSAMLphp distribution implements a filter. Beyond that, you are encouraged to create your own filters and share with the community. If you have created a cool Auth Proc Filter that does something useful, let us know, and we may share it on the SimpleSAMLphp web site.

When you know the class definition of a filter, and the priority, the simple way to configure the filter is:

20 => 'core:TargetedID',

This is analogous to:

20 => array(
    'class' => 'core:TargetedID'
),

Some Auth Proc Filters have optional or required parameters. To send parameters to Auth Proc Filters, you need to choose the second of the two alernatives above. Here is an example of provided parameters to the consent module:

90 => array(
    'class'     => 'consent:Consent', 
    'store'     => 'consent:Cookie', 
    'focus'     => 'yes', 
    'checked'   => TRUE
),

1.1 Filters in config.php

Global Auth Proc Filters are configured in the config.php file. You will see that the config template already includes an example configuration.

There are two config parameters:

The filters in authproc.idp will be executed at the IdP side regardless of which IdP and SP entity that is involved.

The filters in authproc.sp will be executed at the SP side regardless of which SP and IdP entity that is involved.

1.2 Filters in metadata

Filters can be added both in hosted and remote metadata. Here is an example of a filter added in a metadata file:

'__DYNAMIC:1__' => array(
    'host'              =>  '__DEFAULT_',
    'privatekey'        =>  'example.org.pem',
    'certificate'       =>  'example.org.crt',
    'auth'              =>  'feide',
    'authproc' => array(
        40 => 'core:AttributeRealm',
    ),
)

The example above is in saml20-idp-hosted.

2 Auth Proc Filters included in the SimpleSAMLphp distribution

The following filters are included in the SimpleSAMLphp distribution:

3 Writing your own Auth Proc Filter

Look at the included Auth Proc Filters as examples. Copy the classes into your own module and start playing around.

Authentication processing filters are created by creating a class under Auth/Process/ in a module. This class is expected to subclass SimpleSAML_Auth_ProcessingFilter. A filter must implement at least one function - the process(&$request)-function. This function can access the $request-array to add, delete and modify attributes, and can also do more advanced processing based on the SP/IdP metadata (which is also included in the $request-array). When this function returns, it is assumed that the filter has finished processing.

If a filter for some reason needs to redirect the user, for example to show a web page, it should save the current request. Upon completion it should retrieve the request, update it with the changes it is going to make, and call SimpleSAML_Auth_ProcessingChain::resumeProcessing. This function will continue processing the next configured filter.

Requirements for authentication processing filters:

Don't hestitate to ask on the SimpleSAMLphp mailinglist if you have problems or questions, or want to share your Auth Proc Filter with others.