grunt-crossdomain-xml

Grunt plugin which generates a crossdomain.xml file

npm install grunt-crossdomain-xml
8 downloads in the last week
9 downloads in the last month

grunt-crossdomain-xml

Grunt plugin for generating crossdomain.xml.

NPM version Dependency Status Build Status

About crossdomain.xml

You can grab more info about the crossdomain.xml file on the dedicated Adobe page.

Installation

Install npm package:

npm install grunt-crossdomain-xml

Add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-crossdomain-xml');

Configuration

crossdomainxml is a multitask, so you can use crossdomainxml:dist and register some other tasks than "dist":

    grunt.initConfig({

        crossdomainxml: {
            dist: {
                dest: 'src/',
                siteControl: 'master-only',
                allowAccessFrom: [
                    {
                        'domain': '*'
                    },
                    {
                        'domain': '*.example.org',
                        'secure': false,
                        'toPorts': ['9865', '9000:9100']
                    }
                ],
                allowHttpRequestHeadersFrom: [
                    {
                        'domain': '*.test.com'
                    },
                    {
                        'domain': '*.example.org',
                        'headers': ['SOAPAction', 'AnotherHeader'],
                        'secure': false
                    }
                ]
            }
        }

    });

The above configuration should give you the following src/crossdomain.xml file:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="master-only"/>
    <allow-access-from domain="*"/>
    <allow-access-from domain="*.example.org" secure="false" to-ports="9865,9000:9100"/>
    <allow-http-request-headers-from domain="*.test.com"/>
    <allow-http-request-headers-from domain="*.example.org" secure="false" headers="SOAPAction,AnotherHeader"/>
</cross-domain-policy>

Options

  • dest: String (./ by default)

    Path where robots.txt will be created

  • siteControl: Object (none by default)

    Can be none, master-only, by-content-type, by-ftp-filename, all

  • allowAccessFrom: Object (none by default)

    Hash of your access policy. You can provide as many hashes with domains as you want. Note that you can give an array of values for toPorts in order to allow multiple ports or port ranges. You can also pass a full comma-separated list of ports as a string. Here, you would enter 'toPorts': '9865,9000:9100

Build from sources

There is a build process (which involves Grunt) for this Grunt task. Basically, the process will check the code with JSHint and JSCS, and execute some tests.

You can launch this process with the grunt command:

grunt

Or if you just want to test (and not check code):

grunt test

devDependency Status Built with Grunt

License

This plugin for Grunt is released under the MIT License.

npm loves you