Skip to content

Commit 34122cc

Browse files
committed
Fixes #164
1 parent fa51014 commit 34122cc

File tree

7 files changed

+34
-16
lines changed

7 files changed

+34
-16
lines changed

AUTHORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ Noteworthy contributors
1111
David McFadzean (static assets management) https://github.com/macterra
1212
Bradly Sharpe https://github.com/brad7928
1313
Collin Reynolds https://github.com/creynold
14-
jon r https://github.com/almereyda
14+
jon r https://github.com/almereyda
15+
everpcpc (LDAP support) https://github.com/everpcpc

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 1.7.0, September 18th, 2016
2+
==================================
3+
4+
- Fixes #164 (ProxyPath not used on /login)
5+
- Adds LDAP authentication support (@everpcpc). Requires manual installation of `passport-ldapauth`
6+
17
Version 1.6.1, January 27th, 2016
28
==================================
39

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ For GitHub, follow these instructions (you need to be logged in in GitHub):
133133
* Now you need to copy the `Client ID` and `Client secret` in your jingo config file in the proper places
134134

135135
The _ldap_ method uses `url` as the ldap server url, and optionally a `bindDn` and `bindCredentials` if needed. The `searchBase` and `searchFilter` are required for searching in the tree.
136+
Since we want to install the (binary) support to LDAP only when needed, please _manually_ `npm install passport-ldapauth` to use the LDAP support.
136137

137138
The _local_ method uses an array of `username`, `passwordHash` and optionally an `email`. The password is hashed using a _non salted_ SHA-1 algorithm, which makes this method not the safest in the world but at least you don't have a clear text password in the config file. To generate the hash, use the `--hash-string` program option: once you get the hash, copy it in the config file.
138139

@@ -286,6 +287,7 @@ Configuration options reference
286287
#### authentication.ldap.enabled (boolean: false)
287288

288289
Enable or disable authentication via LDAP logins
290+
Requires manual installation of `passport-ldapauth` module via npm
289291

290292
#### authentication.ldap.url
291293
#### authentication.ldap.bindDn

jingo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var program = require("commander"),
1717

1818
global.Git = require("./lib/gitmech");
1919

20-
program.version("1.6.1")
20+
program.version("1.7.0")
2121
.option("-c, --config <path>", "Specify the config file")
2222
.option("-#, --hash-string <string>", "Create an hash for a string")
2323
.option("-l, --local", "Listen on localhost only")

lib/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module.exports.initialize = function (config) {
172172

173173
function requireAuthentication(req, res, next) {
174174
if (!res.locals.user) {
175-
res.redirect("/login");
175+
res.redirect(res.locals.proxyPath + "/login");
176176
}
177177
else {
178178
next();

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jingo",
3-
"version": "1.6.1",
3+
"version": "1.7.0",
44
"description": "A nodejs based wiki engine",
55
"author": "Claudio Cicali <claudio.cicali@gmail.com>",
66
"keywords": [
@@ -46,7 +46,6 @@
4646
"passport": "^0.2.0",
4747
"passport-github": "^0.1.5",
4848
"passport-google-oauth": "^0.1.5",
49-
"passport-ldapauth": "^0.3.1",
5049
"passport-local": "^1.0.0",
5150
"semver": "^2.3.2",
5251
"serve-favicon": "^2.1.7",

routes/auth.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ var router = require("express").Router(),
44
passportLocal = require("passport-local"),
55
passportGoogle = require("passport-google-oauth"),
66
passportGithub = require("passport-github").Strategy,
7-
passportLDAP = require("passport-ldapauth"),
87
tools = require("../lib/tools");
98

109
var auth = app.locals.config.get("authentication");
10+
11+
// Additional LDAP support only if needed
12+
var passportLDAP;
13+
if (auth.ldap.enabled) {
14+
passportLDAP = require("passport-ldapauth");
15+
}
16+
1117
var passport = app.locals.passport;
1218
var proxyPath = app.locals.config.getProxyPath();
1319

@@ -34,11 +40,13 @@ router.get("/auth/github/callback", passport.authenticate("github", {
3440
failureRedirect: proxyPath + "/login"
3541
}));
3642

37-
router.post("/auth/ldap", passport.authenticate("ldapauth", {
38-
successRedirect: proxyPath + "/auth/done",
39-
failureRedirect: proxyPath + "/login",
40-
failureFlash: true
41-
}));
43+
if (auth.ldap.enabled) {
44+
router.post("/auth/ldap", passport.authenticate("ldapauth", {
45+
successRedirect: proxyPath + "/auth/done",
46+
failureRedirect: proxyPath + "/login",
47+
failureFlash: true
48+
}));
49+
}
4250

4351
if (auth.google.enabled) {
4452
var redirectURL = auth.google.redirectURL || app.locals.baseUrl + "/oauth2callback";
@@ -165,11 +173,13 @@ passport.deserializeUser(function (user, done) {
165173
}
166174

167175
// for ldap auth
168-
if (!user.displayName && user.uid) {
169-
user.displayName = user.uid;
170-
}
171-
if (!user.email && user.mail) {
172-
user.email = user.mail;
176+
if (auth.ldap.enabled) {
177+
if (!user.displayName && user.uid) {
178+
user.displayName = user.uid;
179+
}
180+
if (!user.email && user.mail) {
181+
user.email = user.mail;
182+
}
173183
}
174184

175185
if (!user.email) {

0 commit comments

Comments
 (0)