node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »



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:


The "grunt-connect-http-auth" task

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


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.

  connect: {
      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 [

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) {[



  • Better tests

Release History

(Nothing yet)