PHP code example of informaticauco / simplesamlphp-module-ucofilter

1. Go to this page and download the library: Download informaticauco/simplesamlphp-module-ucofilter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

informaticauco / simplesamlphp-module-ucofilter example snippets




use SimpleSAML\Modules\UcoFilter\Auth\Process\UcoFilter;

$config = array(
    // ...
    
    50 => array(
        'class' => UcoFilter::class,
        // (Optional) This filter only is executed is almost one rule is true
        // Default -> 'rules' => ['true']
        'rules' => [
            '"sp-remote-id" in request["saml:RequesterID"]',
        ],
        // (Optional) Reset the next attributes before to add new values
        // Default -> 'reset' => []
        'reset' => [
            'eduPersonPrincipalName',
        ],
        // (Required) Create new attributes
        'mapping' => array (
            // Concatenation example without rules
            // firstName, middleName and lastName exists in Attributes.
            'commonName' => 'firstName[0]~" "~middleName[0]~" "~lastName[0]',
            
            // Multiple attributes
            'eduPersonPrincipalName' => [
                'uid[0]',  
                'mail[0]',
                'commonName[0]' // previous attributes are available
            ],
            
            // Complete syntax with rules
            'groups' => [
                // value expression => rule expression
                // value only is added if the rule is true
                '"staff"' => 'in_attribute(attributes["uid"], ["username1", "username2])',
                '"guest"', // always true
                '"student"' => 'attributes["uid"][0] matches "/^alum\d+/"',
            ],
        ),
    ),
    // ...    
);