Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid roster leak, avoid remote resources, LDAP tweaks #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clientapp/helpers/avatarHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
var crypto = require('crypto');

module.exports.getGravatar = function (jid) {
if (!SERVER_CONFIG.gravatarEnabled)
return {
uri: '/images/user.jpg'
};
var gID = crypto.createHash('md5').update(jid).digest('hex');
return {
uri: 'https://gravatar.com/avatar/' + gID + '?s=80&d=mm'
Expand Down
3 changes: 3 additions & 0 deletions clientapp/models/ldapUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = BaseCollection.extend({
fetch: function (cb) {
var self = this;

if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users', ldapUser.ldapData(), function(users) {
var toRemove = [];
for ( var i = 0; i < self.models.length; i++) {
Expand Down Expand Up @@ -52,6 +53,7 @@ module.exports = BaseCollection.extend({
addUser: function (id) {
var self = this;

if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users/add', ldapUser.ldapData({newUid: id}), function(result) {
result = JSON.parse(result);
if (result) {
Expand All @@ -62,6 +64,7 @@ module.exports = BaseCollection.extend({
deleteUser: function (id) {
var self = this;

if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users/delete', ldapUser.ldapData({removeUid: id}), function(result) {
result = JSON.parse(result);
if (result) {
Expand Down
2 changes: 1 addition & 1 deletion clientapp/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports.body = function anonymous(locals) {
exports.head = function anonymous(locals) {
var buf = [];
with (locals || {}) {
buf.push('<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0"/><meta name="apple-mobile-web-app-capable" content="yes"/><link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Lato:400,700"/><link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"/>');
buf.push('<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0"/><meta name="apple-mobile-web-app-capable" content="yes"/><link rel="stylesheet" type="text/css" href="/css/lato.css"/><link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css"/>');
}
return buf.join("");
};
Expand Down
4 changes: 2 additions & 2 deletions clientapp/templates/head.jade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
meta(name="viewport", content="width=device-width,initial-scale=1.0,maximum-scale=1.0")
meta(name="apple-mobile-web-app-capable", content="yes")
link(rel="stylesheet", type="text/css", href="//fonts.googleapis.com/css?family=Lato:400,700")
link(rel="stylesheet", type="text/css", href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css")
link(rel="stylesheet", type="text/css", href="/css/lato.css")
link(rel="stylesheet", type="text/css", href="/css/font-awesome.min.css")
1 change: 1 addition & 0 deletions dev_config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"server": {
"name": "Kaiwa",
"domain": "example.com",
"gravatarEnabled": false,
"wss": "wss://example.com:5281/xmpp-websocket/",
"muc": "chat.example.com",
"startup": "groupchat/room%40chat.example.com",
Expand Down
1 change: 1 addition & 0 deletions dev_config_ldap.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"server": {
"name": "Kaiwa",
"domain": "example.com",
"gravatarEnabled": false,
"wss": "wss://example.com:5281/xmpp-websocket/",
"muc": "chat.example.com",
"startup": "groupchat/room%40chat.example.com",
Expand Down
4 changes: 4 additions & 0 deletions public/css/font-awesome.min.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/css/lato.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
src: local('Lato Regular'), local('Lato-Regular'), url('../fonts/latoregular.ttf') format('truetype');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
src: local('Lato Bold'), local('Lato-Bold'), url('../fonts/latobold.ttf') format('truetype');
}
Binary file added public/fonts/FontAwesome.otf
Binary file not shown.
Binary file added public/fonts/fontawesome-webfont.eot
Binary file not shown.
655 changes: 655 additions & 0 deletions public/fonts/fontawesome-webfont.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/fontawesome-webfont.ttf
Binary file not shown.
Binary file added public/fonts/fontawesome-webfont.woff
Binary file not shown.
Binary file added public/fonts/fontawesome-webfont.woff2
Binary file not shown.
Binary file added public/fonts/latobold.ttf
Binary file not shown.
Binary file added public/fonts/latoregular.ttf
Binary file not shown.
Binary file added public/images/user.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var templatizer = require('templatizer');
var async = require('async');
var LDAP = require('ldapjs');

config.ldapEnabled = !(!config.ldap || !config.ldap.address || !config.ldap.base);

String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
Expand Down Expand Up @@ -50,9 +52,11 @@ app.get('/sounds/*', function (req, res) {
res.redirect("./public" + req.baseUrl);
});

if (config.ldapEnabled) {

function connectLDAP(req, cb) {

if (!config.ldap || !config.ldap.address || !config.ldap.base) {
if (!config.ldapEnabled) {
cb(true);
return;
}
Expand Down Expand Up @@ -298,6 +302,8 @@ app.post('/ldap/users/delete', function (req, res) {

});

}

app.get('/oauth/login', function (req, res) {
res.redirect('https://apps.andyet.com/oauth/authorize?client_id=' + config.andyetAuth.id + '&response_type=token');
});
Expand Down