Permalink
Browse files

trying some stuff

  • Loading branch information...
1 parent ba83dac commit d787aee4cf691017d6568951d91119bf506910b1 @xymor committed May 20, 2012
View
@@ -0,0 +1,6 @@
+/npm-debug.log
+/node_modules
+/.monitor
+/public/stylesheets/style.css
+/lib/node-ldapauth/ldapauth.node
+/lib/expresso/
View
@@ -0,0 +1,17 @@
+var taks = require('jake').task;
+var sys = require('sys');
+var exec = require('child_process').exec;
+
+function puts(error, stdout, stderr) {
+ console.log('stdout: ' + stdout);
+ console.log('stderr: ' + stderr);
+ if (error !== null) {
+ console.log('exec error: ' + error);
+ }
+}
+
+task('compile', function(t){
+ exec("cd lib/node-ldapauth && ./build.sh", puts);
+});
+
+task('default', ['compile']);
View
@@ -0,0 +1,30 @@
+==== /misc ====
+
+Barramisc is a simple Google+ based webapp for intranets.
+
+==== Setup ====
+
+$> cd barramisc/
+$> npm install -g jake
+$> npm install -g nodemon
+$> npm update
+$> jake compile
+
+You need an instance of MongoDB up and running on the default port.
+
+==== Testing the app ====
+
+$> cd barramisc/
+$> expresso
+
+==== Running the app ====
+
+$> cd barramisc/
+$> node barramisc.js
+
+Point your favorite browser to http://localhost:3000.
+
+==== Authentication Mock ====
+
+We have an authentication mock, just in case you not have any LDAP server at hand.
+Just go to "/mock_login" and enjoy it.
View
@@ -0,0 +1,69 @@
+exports.dynamicHelpers = {
+ flash: function(req, res) {
+ var messages = "";
+ ['error','info'].forEach(function(type){
+ messages += req.flash(type).join(';\n');
+ });
+
+ return messages;
+ },
+
+ session: function(req, res) {
+ return req.session;
+ }
+};
+
+exports.html_helpers = function() {
+
+ var EN_AMP_RE = /&/g;
+ var EN_LT_RE = /</g;
+ var EN_GT_RE = />/g;
+ var EN_QUOT_RE = /"/g;
+ var EN_SINGLE_RE = /'/g;
+
+ // encode text into HTML to avoid XSS attacks.
+ // underscore templates do not auto encode. If in doubt, use this!
+ function htmlEncode(text){
+ text = ""+text;
+ text = text.toString().replace(EN_AMP_RE, "&amp;");
+ text = text.replace(EN_LT_RE, "&lt;");
+ text = text.replace(EN_GT_RE, "&gt;");
+ text = text.replace(EN_QUOT_RE, "&quot;");
+ text = text.replace(EN_SINGLE_RE, "&#39;");
+ return text;
+ }
+
+ var DE_GT_RE = /\&gt\;/g;
+ var DE_LT_RE = /\&lt\;/g;
+ var DE_QUOT_RE = /\&quot\;/g;
+ var DE_SINGLE_RE = /\&#39\;/g;
+
+ function htmlDecode(text){
+ text = ""+text;
+ text = text.toString().replace(DE_GT_RE, ">");
+ text = text.replace(DE_LT_RE, "<");
+ text = text.replace(DE_QUOT_RE, '"');
+ text = text.replace(DE_QUOT_RE, '"');
+ text = text.replace(DE_SINGLE_RE, '\'');
+ return text;
+ }
+
+ //from http://gist.github.com/492947 and http://daringfireball.net/2010/07/improved_regex_for_matching_urls
+ var GRUBERS_URL_RE = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig
+
+ function linkfy(text) {
+ return text.replace(GRUBERS_URL_RE, function(url) {
+ var displayURL = url;
+ var targetURL = (/^\w+\:\//.test(url)?'':'http://') + url;
+ return '<a href="'+htmlEncode(targetURL)+'">'+htmlEncode(displayURL)+'</a>';
+ });
+ }
+
+ return {
+ decode: htmlDecode,
+ encode: htmlEncode,
+ linkfy: linkfy
+ }
+
+}
+
View
@@ -0,0 +1,44 @@
+LDAPAuth = function(server, port) {
+ if(server != undefined)
+ this.config.server = server;
+ if(port != undefined)
+ this.config.port = port;
+};
+
+LDAPAuth.prototype = {
+ config: { server: 'gurgel', port: 389 },
+
+ login: function(login, password, okCallBack, errCallBack) {
+ var ldap = require('./node-ldapauth/ldapauth');
+ ldap.authenticate(this.config.server, this.config.port,'IDEAIS\\' + login, password, function(err, result){
+ if(err) {
+ errCallBack(err);
+ } else {
+ okCallBack(result);
+ }
+ });
+ }
+};
+
+MockAuth = function() {};
+
+MockAuth.prototype = {
+ login: function(login, password, okCallBack, errCallBack) {
+ okCallBack();
+ }
+}
+
+var AuthProvider = function() {};
+
+AuthProvider.prototype = {
+ getLDAPAuth: function(server, port) {
+ return new LDAPAuth(server, port);
+ },
+
+ getMockAuth: function() {
+ return new MockAuth();
+ }
+};
+
+exports.AuthProvider = AuthProvider;
+
@@ -0,0 +1,2 @@
+.lock-wscript
+build
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+node-waf configure build && cp build/default/ldapauth.node ./
Oops, something went wrong. Retry.

0 comments on commit d787aee

Please sign in to comment.