We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37260
    • 8 Posts
    Hi all,

    I would like to know how to "secure" simplx_rpc. I have searched for almost two days (!!) and I am completly lost...
    The pb is that I have a js on my page (therefore viewable by anyone) that query my snippet through the simplx_rpc ressource page, but then anyone could change the snippet name in the query and get the result...
    So how should I restrict the usage to only one snippet?

    Any clue would be very much appreciated!!
    Thanks!

    Ps: I have tried things with element groups acl, web context etc... but didn't worked out how to configure it well...
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Well, I would put the javascript into a separate file and load it via
      <script href='blah'></script>

      in the first place. Or you could use a snippet, which first sets a CONSTANT variable then includes a .php file that checks for the constant variable passed by the snippet and then generates the HTML containing the javascript (or the link to same) as its output. That included file can be protected via .htaccess with a specific deny/allow block to deny all access to that specific .php file; since it's included internally the page will still work, but any attempt to access the file from the outside will fail. I have all my config.inc.php files for various apps (such as the backup module) protected in this manner. The included file can also be stored outside of the web root, if your server is configured to allow that.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 37260
        • 8 Posts
        Thank you Susan but I'm not sure to understand what you mean... You describe a way to protect some php code? (sorry but I ain't really "code friendly").

        What I meant is that when I use the "plugin" simplx_rpc for revo, I create a page (ressource) with only the simplx snippet in it. Then I can send some kind of json query to that ressource href to make it execute a snippet of my choice and get back the result as a json obj.

        In my case I have a gallery page with thumbnails. When you click on a thumbnail, there is some js code that compute the screen size and then send a json query to the simplx ressource which then execute my snippet and then a json list of my images is returned to the original page.... (not sure that it is clear!!)

        The pb is that the simplx ressource may call any snippet, so how should I restrict it to only be able to call some of the snippets?

        Thanks!