Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to set up HTTP Basic Authentication for a Meteor app?

I have a simple Meteor application demo which I'd like to deploy, but I'd like it to be password protected. No need for individual user account -- a single login / pword is sufficient for now.

Any advice? I realize Meteor has an auth branch under active development, and so a full featured solution will be available before long. But if anyone can advise a path of least resistance for the short term, I'd be grateful.

thanks

like image 442
doublea Avatar asked Sep 01 '12 18:09

doublea


1 Answers

Yes, it's possible if u write a little piece of connect middleware and then slip it into the beginning 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;
      })
    });
  });
}
like image 147
Jabbslad Avatar answered Oct 12 '22 12:10

Jabbslad