Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    grunt-connect-http-authpublic

    grunt-connect-http-auth

    Http-auth middleware for grunt-connect.

    Getting Started

    This plugin requires Grunt ~0.4.1

    If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

    npm install grunt-connect-http-auth --save-dev

    Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

    grunt.loadNpmTasks('grunt-connect-http-auth');

    The "grunt-connect-http-auth" task

    Grunt-connect-http-auth is using http-auth of gevorg as a middleware layer to add authenication.

    Configuration

    In your project's Gruntfile, add a section named auth to the connect data object passed into grunt.initConfig(). You find the configurations in the http-auth project.

    grunt.initConfig({
      connect: {
        auth:{
          authRealm : "Private server",
          authList : ['foo:bar']
        }
      },
    })

    Adding the middleware

    Expose the http-auth function to use in the middleware, at the top of the grunt file:

    var authRequest = require('grunt-connect-http-auth/lib/utils').authRequest;

    Add the middleware call from the connect option middleware hook

    connect: {
        livereload: {
            options: {
                middleware: function (connect) {
                    return [
                        authRequest
                    ];
                }
            }
        }
    }

    Adding the "configureHttpAuth" task to the server task

    For the server task, add the "configureHttpAuth" task before the "connect" task

    grunt.registerTask('server', function (target) {
        grunt.task.run([
            'configureHttpAuth',
            'connect:livereload'
        ]);
    });

    Thanks

    Todo

    • Better tests

    Release History

    (Nothing yet)

    Keywords

    none

    install

    npm i grunt-connect-http-auth

    Downloadsweekly downloads

    16

    version

    0.1.2

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar