Is there an easy way to configure basic HTTP authentication for a Meteor application?

I have a simple demo of Meteor applications that I would like to deploy, but I would like it to be password protected. No need for a separate user account - just one login / password.

Any tips? I understand that Meteor has an active branch, and therefore a full-featured solution will be available soon. But if someone can advise the path of least resistance for a short time, I would be grateful.

thank

+5
source share
2 answers

Yes, perhaps if you write a small piece of middleware, then paste it at the top of the stack. Try using this: -

if (Meteor.is_server) {
  Meteor.startup(function () {
    var require = __meteor_bootstrap__.require;
    var connect = require('connect');

    __meteor_bootstrap__.app.stack.splice(0, 0, {
      route: '',
      handle: connect.basicAuth(function(user, pass){
        return 'guest' == user & 'password' == pass;
      })
    });
  });
}
+4

@Jabbslad, 0.6.5:

if (Meteor.is_server) {
  Meteor.startup(function () {
    WebApp.connectHandlers.stack.splice(0, 0, {
      route: '',
      handle: WebApp.__basicAuth__(function(user, pass){
        return 'guest' == user & 'password' == pass;
      })
    });
  });
}

connect.basicAuth WebApp.__basicAuth__, Npm.require("connect") Meteor 0.6.5, .

+2

All Articles