Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Add HTTP Basic Auth support to your Meteor application
JavaScript
branch: master
Failed to load latest commit information.
.gitignore .gitignore
README.md Update README.md
basic-auth.js update for Meteor 1.0.4
package.js Update package.js

README.md

basic-auth

A Meteor package of Connect Basic Auth, allowing you to easily Add HTTP Basic Auth support to your application.

Add Package

meteor add jabbslad:basic-auth

Usage

Username and Password

Create new HttpBasicAuth instance passing in a username and password then call protect method.

var basicAuth = new HttpBasicAuth("guest", "password");
basicAuth.protect();

Authentication Function

Create new HttpBasicAuth instance passing in a function (that returns true or false) then call protect method.

var basicAuth = new HttpBasicAuth(function(username, password) {
    return 'guest' == username & 'password' == password;
});
basicAuth.protect();

Protecting Certain Urls

By default, when you call protect with no arguments it will protect your entire site. If you want to protect certain routes do as follows:-

var basicAuth = new HttpBasicAuth("guest", "password");
basicAuth.protect(['/secretstuff', '/homemovies']);

or you can do this:-

var basicAuth = new HttpBasicAuth("guest", "password");
basicAuth.protect(['/homemovies']);
basicAuth.protect(['/secretstuff']);

or this to use different passwords:-

var basicAuthMovies = new HttpBasicAuth("movies", "password");
basicAuthMovies(['/homemovies']);

var basicAuthStuff = new HttpBasicAuth("stuff", "password");
basicAuthStuff.protect(['/secretstuff']);

Other Stuff

Realms

var basicAuth = new HttpBasicAuth("guest", "password", "My Realm");
basicAuth.protect();

Thanks

Something went wrong with that request. Please try again.