A Meteor package of Connect Basic Auth, allowing you to easily Add HTTP Basic Auth support to your application.
meteor add jabbslad:basic-auth
Create new HttpBasicAuth
instance passing in a username and password then call protect
method.
var basicAuth = new HttpBasicAuth("guest", "password");
basicAuth.protect();
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();
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']);
var basicAuth = new HttpBasicAuth("guest", "password", "My Realm");
basicAuth.protect();
- masarum - Fix for Meteor 1.0.4