Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Secure with HTTP Authentication for Cloud9 IDE

Add Secure with HTTP Authentication for Cloud9 IDE.

git clone https://github.com/ajaxorg/cloud9.git
git submodule update --init --recursive
git apply cloud9.patch
git clone git://github.com/semu/connect-basic-auth.git support/connect-basic-auth
node bin/cloud9.js -c config.js 

Open the url http://127.0.0.1:3000/ when prompt the authorization,username is "username" and password is "password". Modify secure.user and secure.password in config.js to your own authorization.

Enjoy it.

diff --git a/config.js b/config.js
index 5f4fc26..2564fe7 100644
--- a/config.js
+++ b/config.js
@@ -3,4 +3,9 @@
exports.Config = {
ip: "127.0.0.1",
port: 3000,
gaeLocalPath: ".",
-};
+ // add for secure
+ secure: {
+ user: "username",
+ password: "password"
+ }
+};
diff --git a/bin/cloud9.js b/bin/cloud9.js
index a3b15c9..2debbed 100755
--- a/bin/cloud9.js
+++ b/bin/cloud9.js
@@ -28,6 +28,12 @@
var options = Parser.parse([
var pref = ( value.charAt(0) == "/" ) ? "" : process.cwd() + "/";
return require(pref + value.replace(".js", "")).Config;
}
+ },
+ // add for secure
+ {short: "s", long: "secure", description: "Secure Cloud9 with user:password for HTTP basic acc
+ var posDelimeter = value.indexOf(':');
+ return {user: value.substr(0, posDelimeter), password: value.substr(posDelimeter + 1)}
+ }
}
], true);
diff --git a/server/cloud9/index.js b/server/cloud9/index.js
index 34c744a..0cef23e 100644
--- a/server/cloud9/index.js
+++ b/server/cloud9/index.js
@@ -5,6 +5,7 @@
require("../../support/paths");
var Connect = require("connect");
+var ConnectAuth = require('basicAuth'); // add for secure
var IO = require("socket.io");
var Fs = require("fs");
var Path = require("path");
@@ -17,7 +18,8 @@
exports.main = function(options) {
port = options.port,
ip = options.ip,
user = options.user,
- group = options.group;
+ group = options.group,
+ secure = options.secure; // add for secure
if (!Path.existsSync(projectDir))
throw new Error("Workspace directory does not exist: " + projectDir);
@@ -64,6 +66,12 @@
exports.main = function(options) {
};
var server = Connect.createServer();
+ // add for secure
+ if (secure) {
+ server.use(ConnectAuth(function (user, password) {
+ return user === secure.user && password == secure.password;
+ }));
+ }
//server.use(Connect.logger());
server.use(Connect.conditionalGet());
server.use(Connect.cookieDecoder());
@okev

This comment has been minimized.

Show comment
Hide comment
@okev

okev Nov 9, 2011

If applying this to the version of cloud9 installed via npm, you'll need to add
require.paths.unshift(__dirname + "/connect-basic-auth/lib");
to ./support/paths.js

okev commented Nov 9, 2011

If applying this to the version of cloud9 installed via npm, you'll need to add
require.paths.unshift(__dirname + "/connect-basic-auth/lib");
to ./support/paths.js

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 11, 2012

hello,

I have trouble on implementing this. Do you have a simplified explanation on how to implement this?

ghost commented Sep 11, 2012

hello,

I have trouble on implementing this. Do you have a simplified explanation on how to implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment