<?php
error_reporting(E_ERROR);

$config = array(
    'baseurlpath' => '/',
    'certdir' => __DIR__.'/certs/',
    'loggingdir' => __DIR__ . '/../../../../var/log/',
    'datadir' => __DIR__ . '/../../../../var/cache/',
    'tempdir' => '/tmp/simplesaml',
    'debug' => true,
    'showerrors' => true,
    'errorreporting' => true,
    'debug.validatexml' => false,
    'auth.adminusername' => 'admin',
    'auth.adminpassword' => 'pfad#1',
    'admin.protectindexpage' => true,
    'admin.protectmetadata' => true,
    'secretsalt' => 'akdjkJASKDJkwieakjSdkidwhjkjasdsda',
    'technicalcontact_name' => 'Webmaster',
    'technicalcontact_email' => 'webmaster@lifestyle.eu',
    'timezone' => 'UTC',
    'logging.level' => SimpleSAML\Logger::DEBUG,
    'logging.handler' => 'file',
    'logging.facility' => defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER,
    'logging.processname' => 'simplesamlphp-idp',
    'logging.logfile' => 'simplesamlphp.log',
    'statistics.out' => array(),
    'enable.saml20-idp' => true,
    'enable.shib13-idp' => false,
    'enable.adfs-idp' => false,
    'enable.wsfed-sp' => false,
    'enable.authmemcookie' => false,
    'session.duration' => 8 * (60 * 60), // 8 hours.
    'session.datastore.timeout' => (4 * 60 * 60), // 4 hours
    'session.state.timeout' => (60 * 60), // 1 hour
    'session.cookie.name' => 'SimpleSAMLSessionID',
    'session.cookie.lifetime' => 0,
    'session.cookie.path' => '/',
    'session.cookie.domain' => null,
    'session.cookie.secure' => false,
    'session.disable_fallback' => false,
    'enable.http_post' => false,
    'session.phpsession.cookiename' => null,
    'session.phpsession.savepath' => null,
    'session.phpsession.httponly' => false,
    'session.authtoken.cookiename' => 'SimpleSAMLAuthToken',
    'session.rememberme.enable' => false,
    'session.rememberme.checked' => false,
    'session.rememberme.lifetime' => (14 * 86400),
    'language.available' => array('en', 'de', 'nl'),
    'language.rtl' => array(),
    'language.default' => 'en',
    'language.parameter.name' => 'language',
    'language.parameter.setcookie' => true,
    'language.cookie.name' => 'language',
    'language.cookie.domain' => null,
    'language.cookie.path' => '/',
    'language.cookie.lifetime' => (60 * 60 * 24 * 900),
    'attributes.extradictionary' => null,
    'theme.use' => 'lifestyle:lifestyle',
    'default-wsfed-idp' => 'urn:federation:pingfederate:localhost',
    'idpdisco.enableremember' => true,
    'idpdisco.rememberchecked' => true,
    'idpdisco.validate' => true,
    'idpdisco.extDiscoveryStorage' => null,
    'idpdisco.layout' => 'dropdown',
    'shib13.signresponse' => true,
    'authproc.idp' => array(
        // Remove invalid characters (non UTF-8 and more)
        // from attributes
        // @see http://www.w3.org/TR/REC-xml/#charsets
        1 => array(
            'class' => 'core:PHP',
            'code' => '
$regex = \'/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u\';
foreach ($attributes as $key => $value) {
    if (is_array($value)) {
        foreach ($value as $k => $v) {
            $attributes[$key][$k] = preg_replace($regex, \' \', $v);
        }
    } else {
        $attributes[$key] = preg_replace($regex, \' \', $value);
    }
}
            ',
        ),

        // Validate MFA token
        2 => 'lifestyle:WebserviceMfa',

        // After MFA has been processed, login status can be set
        3 => 'lifestyle:WebserviceLoginStatus',

        // Add application attributes and roles
        4 => 'lifestyle:WebserviceAttributes',

        // Adopts language from attribute to use in UI
        30 => 'core:LanguageAdaptor',

        45 => array(
            'class' => 'core:StatisticsWithAttribute',
            'attributename' => 'realm',
            'type' => 'saml20-idp-SSO',
        ),

        /* When called without parameters, it will fallback to filter attributes ‹the old way›
         * by checking the 'attributes' parameter in metadata on IdP hosted and SP remote.
         */
        50 => 'core:AttributeLimit',

        // If language is set in Consent module it will be added as an attribute.
        99 => 'core:LanguageAdaptor',
    ),

    /*
     * Authentication processing filters that will be executed for all SPs
     * Both Shibboleth and SAML 2.0
     */
    'authproc.sp' => array(
        // All users will be members of 'users' and 'members'
        61 => array('class' => 'core:AttributeAdd', 'groups' => array('users', 'members')),

        // Adopts language from attribute to use in UI
        90 => 'core:LanguageAdaptor',

    ),


    'metadata.sources' => array(
        array('type' => 'flatfile', 'directory' => __DIR__ . '/metadata'),
    ),

    'store.type' => 'lifestyle:SQL',
    'store.sql.dsn' =>
        str_ireplace('pdo_', '', getenv('SYMFONY__DATABASE__DRIVER'))
        . ':host=' . getenv('SYMFONY__DATABASE__HOST')
        . ';port=' . getenv('SYMFONY__DATABASE__PORT')
        . ';dbname=' . getenv('SYMFONY__DATABASE__NAME'),
    'store.sql.username' => getenv('SYMFONY__DATABASE__USER'),
    'store.sql.password' => getenv('SYMFONY__DATABASE__PASSWORD'),
    'store.sql.prefix' => 'idp',

    'memcache_store.servers' => array(
        array(
            array('hostname' => 'localhost'),
        ),
    ),
    'memcache_store.expires' => 36 * (60 * 60), // 36 hours.


    'metadata.sign.enable' => false,
    'metadata.sign.privatekey' => null,
    'metadata.sign.privatekey_pass' => null,
    'metadata.sign.certificate' => null,

    'proxy' => null,
    'trusted.url.domains' => null,

    /**
     * Webservice configuration - communication with user-webservice
     */
    'webservice.client' => array(
        'baseUri' => 'http://ls-sso-uws.local',
        'username' => 'identityProvider-87zhuijhz',
        'password' => 'pfad#4711',
        'salt' => '3Ri/j/Ynwrp3QBjjBoRk96su2OXhlhQZymttdTjaP90',
        'serviceToken' => 'testtoken',
    ),
    'webservice.cyphering' => array(
        'openSslCipherName' => 'AES-256-CBC',
        'mcryptCipherName' => 'MCRYPT_RIJNDAEL_256',
        'mcryptModeName' => 'MCRYPT_MODE_CBC',
        'mcryptAdditionalKey' => '8h79bdsfhoi#hh2jop&9941KWe8Heznsd$jdfsd$0j*df#Fsddf234809jbhsdf3#dsf5768Vboubsdfgui!hjsdffsd?sdfsdfsdfsdf43brfa',
    ),
    'webservice.security' => array(
        'algorithm' => 'sha512',
        'encodeHashAsBase64' => true,
        'iterations' => 5000,
    ),

    'lifestyle.sso.baseurl' => [
        'en' => 'http://ls-sso-wsp.local/en',
        'de' => 'http://ls-sso-wsp.local/de',
    ],
    'lifestyle.password.reset.url' => [
        'en' => 'http://ls-sso-wsp.local/en/resetpassword',
        'de' => 'http://ls-sso-wsp.local/de/resetpassword',
    ],
    'lifestyle.password.forgotten.url' => [
        'en' => 'http://ls-sso-wsp.local/en/lostpassword',
        'de' => 'http://ls-sso-wsp.local/de/lostpassword',
    ],
    'lifestyle.mfa.forgotten.url' => [
        'en' => 'http://ls-sso-wsp.local/en',
        'de' => 'http://ls-sso-wsp.local/en',
    ],
    'lifestyle.privacy.url' => [
        'en' => 'http://ls-sso-wsp.local/en',
        'de' => 'http://ls-sso-wsp.local/en',
    ],
);
