matomo-org / tag-manager

Free Open Source Matomo Tag Manager - A simple way to manage and maintain all of your (third-party) tags on your website.
https://matomo.org
GNU General Public License v3.0
174 stars 58 forks source link

Tag manager requires write access. Is there an alternative solution? #154

Closed MoralCode closed 5 years ago

MoralCode commented 5 years ago

As instructed by my hosting provider, I have not allowed Matomo to write files to anywhere but a tmp folder for security reasons. However, I am unable to publish versions through tag manager because my Matomo instance complains about being unable to write to a folder, which I do not want to allow.

I notice that in the tag manager code snippet, it is trying to access a file js/container_[my container id].js on my Matomo instance. I presume this is the only thing that it needs to write to the directory, so I was wondering if there could be an option to download that file and manually upload it for people who run their own Matomo instance and want to keep their Matomo instanced extra-secure by not allowing the user that runs the web code to write files.

tsteur commented 5 years ago

@MoralCode re download feature see https://github.com/matomo-org/tag-manager/issues/7

As for the writable.... you can configure the location in your config/config.php file. Likely this file doesn't exist and needs to be created. You can configure it like this:


return array(
    'TagManagerContainerStorageDir' => function () {
        // the location where we store the generated javascript or json container files
        return '/js';
    },
    'TagManagerContainerWebDir' => function (\Psr\Container\ContainerInterface $c) {
        // the path under which the containers are available through the web. this may be different to the storage
        // path if using eg htaccess rewrites
        return '/js'
    },
);

you could point the storage to the tmp folder for example and then download the files from there. I haven't tested but you could potentially even point the path to a directory outside the matomo directory like /../tagmanager

MoralCode commented 5 years ago

@tsteur I was able to make it work as you suggested by setting the TagManagerContainerStorageDir to /../tmp, however, because the config file is located in the plugin's config directory, it gets overwritten anytime I update matomo. Is there a way to set this configuration option in matomo's global config.ini.php file?

tsteur commented 5 years ago

you should locate the file in $matomoroot/config/config.php and the file will not be replaced when updating.

MoralCode commented 5 years ago

@tsteur do i have to link to it from the $matomoroot/plugns/TagManager/config/config.php file? or is there a specific path/filename that TagManager looks for inside the matomo configuration directory?

tsteur commented 5 years ago

it's an absolute path within the Matomo directory. You could use /../.. though as well. It's just important they are still served through the web in case you want to embed them into your website directly.