PHP code example of drupalauth / simplesamlphp-module-drupalauth

1. Go to this page and download the library: Download drupalauth/simplesamlphp-module-drupalauth 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/ */

    

drupalauth / simplesamlphp-module-drupalauth example snippets


'drupal-userpass' => array(
    'drupalauth:UserPass',

    // The filesystem path of the Drupal directory.
    'drupalroot' => '/var/www/drupal',

    // Whether to turn on debug
    'debug' => true,

    // Which attributes should be retrieved from the Drupal site.
   'attributes' => array(
       array('field_name' => 'uid', 'attribute_name' => 'uid'),
       array('field_name' => 'roles', 'attribute_name' => 'roles', 'field_property' => 'target_id'),
       array('field_name' => 'name', 'attribute_name' => 'cn'),
       array('field_name' => 'mail', 'attribute_name' => 'mail'),
       array('field_name' => 'field_first_name', 'attribute_name' => 'givenName'),
       array('field_name' => 'field_last_name', 'attribute_name' => 'sn'),
       array('field_name' => 'field_organization', 'attribute_name' => 'ou', 'field_property' => 'target_id'),
   ),
),

'drupal-userpass' => array('drupalauth:External',

 // The filesystem path of the Drupal directory.
 'drupalroot' => '/var/www/drupal',

 // Whether to turn on debug
 'debug' => true,

 // the URL of the Drupal logout page
 'drupal_logout_url' => 'https://www.example.com/drupal/user/logout',

 // the URL of the Drupal login page
 'drupal_login_url' => 'https://www.example.com/drupal/user/login',

 // Which attributes should be retrieved from the Drupal site.
    'attributes' => array(
        array('field_name' => 'uid', 'attribute_name' => 'uid'),
        array('field_name' => 'roles', 'attribute_name' => 'roles', 'field_property' => 'target_id'),
        array('field_name' => 'name', 'attribute_name' => 'cn'),
        array('field_name' => 'mail', 'attribute_name' => 'mail'),
        array('field_name' => 'field_first_name', 'attribute_name' => 'givenName'),
        array('field_name' => 'field_last_name', 'attribute_name' => 'sn'),
        array('field_name' => 'field_organization', 'attribute_name' => 'ou', 'field_property' => 'target_id'),
    ),
),