Search code examples
phpzend-frameworksimplesamlphp

How to integrate simplesamlphp library and update configuration when composer update in Zend Framework3


I installed SIMPLESAMLPHP library with composer using

composer require simplesamlphp/simplesamlphp

For configuration I need to add saml-autoconfig.php file at my SIMPLESAMLPHP library root.But my vendor folder is in .gitignore file.

When I update my composer @production whole configuration with saml-autoconfig.php file gets missing.

I need to configured it when my composer get update.

If anyone have idea.Please help

I need to add following file with configuration

1) In saml-autoconfig.php .

$metadata_url_for = array(
    /* WARNING WARNING WARNING
     *   You MUST remove the testing IdP (idp.oktadev.com) from a production system,
     *   as the testing IdP will allow ANYBODY to log in as ANY USER!
     * WARNING WARNING WARNING
     * For testing with http://saml.oktadev.com use the line below:
     */
     // 'test' => 'http://idp.oktadev.com/metadata',
);

2)vendor/simplesamlphp/config.php

'baseurlpath'=>''

3)vendor/simplesamlphpauthsources.php

 'default-sp'=>''  //its default one .I want to add more sp.

How I add dynamically saml-autoconfig.php this file and set my configuration.


Solution

  • If you want to execute a command after composer finished the install/update process, you can use the post-install-cmd and post-update-cmd options.

    In this case, assuming that the config folder contains your configuration, you need to add this in your composer.json:

    {
        "require": {
            "simplesamlphp/simplesamlphp": "^1.17"
        },
        "scripts": {
            "post-install-cmd": [
                "cp ./config/config.php ./vendor/simplesamlphp/config.php",
                "cp ./config/authsources.php ./vendor/simplesamlphp/authsources.php"
            ],
            "post-update-cmd": [
                "cp ./config/config.php ./vendor/simplesamlphp/config.php",
                "cp ./config/authsources.php ./vendor/simplesamlphp/authsources.php"
            ]
        }
    }
    

    I also downloaded the simplesamlphp library, and the path you reported doesn't seem right. The correct path to install the configuration files should be vendor/simplesamlphp/simplesamlphp/config