CodeboxIDE / codebox

Open source cloud & desktop IDE
https://www.codebox.io
Apache License 2.0
4.12k stars 590 forks source link

Invalid Authentication Data #451

Open imranismail opened 9 years ago

imranismail commented 9 years ago

I have this for my upstart... things are not going too well... when the user is invalid.. it works.. however when the user is valid... it says Invalid Authentication Data....

can someone brighten my day?

var os = require('os');
var path = require('path');
var codebox = require('codebox');

var users = {
  'imran.codely@gmail.com': 'imranismail',
  'dev': 'codemalaysia'
};

var config = {
  'root': path.resolve('/home/dev/codebox/'),
  'title': 'Imran\'s Playground',
  'public': false,
  'dev': false,
  'workspace': {
    'id': null // Default will be a hash of the root path
  },
  'hooks': {
    // Auth: send auth infos and get status and user settings
    'auth': function(data) {
        if (!data.email || !data.token) throw "Need 'token' and 'email' for auth hook";

        var userId = data.email;
        var token = data.token;

        if (!users[userId] || token != users[userId]) throw "Invalid user";

        return {
            'id': userId,
            'name': userId,
            'token': data.token,
            'email': data.email
        };
    }//,
    // Events: send events to a hook
    //'events': process.env.WORKSPACE_HOOK_EVENTS,
    // Settings: send user settings to a hook
    //'settings': process.env.WORKSPACE_HOOK_SETTINGS,
    // Valid addons installation with a hook
    //'addons': process.env.WORKSPACE_HOOK_ADDONS
  },
  'webhook': {
    // Token to pass as Authorization header
    'authToken': null
  },
  'addons': {
    // Base path
    'path': path.resolve(__dirname + '/.codebox/.addons'),
    'defaultsPath': path.resolve(require.resolve('codebox'), '../addons'),
    'tempPath': os.tmpDir(),
    'blacklist': ''.split(',')
  },
  'users': {
    // Max number of collaborators
    'max': 10,

    // Default auth email
    'defaultEmail': null,
    'defaultToken': null,

    // Use git for auth
    'gitDefault': true
  },
  'proc': {
    'urlPattern': 'http://localhost:%d'
  },
  'server': {
    'hostname': '0.0.0.0',
    'port': 8000
  },
  'settings': {
    'path': path.resolve(__dirname + '/settings.json')
  }
};

codebox.start(config).then(function() {
  console.log('codebox is running');
}, function(err) {
  console.log('Error: ', err);
});
chopfitzroy commented 9 years ago

Create your users using the command line: codebox run Workspace/your_project_name -u user1:passwd1,user2:passwd2