Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 591ad40c
authored
Jun 27, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ldap auth
1 parent
c10e69bf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
4 deletions
Dockerfile
app.js
cli/actions.js
package.json
src/auth.js
Dockerfile
View file @
591ad40
...
@@ -9,6 +9,7 @@ WORKDIR /app/code
...
@@ -9,6 +9,7 @@ WORKDIR /app/code
ADD
package.json /app/code/package.json
ADD
package.json /app/code/package.json
ADD
src /app/code/src
ADD
src /app/code/src
ADD
app.js /app/code/app.js
ADD
app.js /app/code/app.js
ADD
app /app/code/app
RUN
npm install
RUN
npm install
EXPOSE
3000
EXPOSE
3000
...
...
app.js
View file @
591ad40
...
@@ -4,11 +4,15 @@
...
@@ -4,11 +4,15 @@
var
express
=
require
(
'express'
),
var
express
=
require
(
'express'
),
morgan
=
require
(
'morgan'
),
morgan
=
require
(
'morgan'
),
passport
=
require
(
'passport'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
compression
=
require
(
'compression'
),
compression
=
require
(
'compression'
),
session
=
require
(
'express-session'
),
bodyParser
=
require
(
'body-parser'
),
bodyParser
=
require
(
'body-parser'
),
cookieParser
=
require
(
'cookie-parser'
),
lastMile
=
require
(
'connect-lastmile'
),
lastMile
=
require
(
'connect-lastmile'
),
multipart
=
require
(
'./src/multipart'
),
multipart
=
require
(
'./src/multipart'
),
auth
=
require
(
'./src/auth.js'
),
files
=
require
(
'./src/files.js'
)(
path
.
resolve
(
__dirname
,
'files'
));
files
=
require
(
'./src/files.js'
)(
path
.
resolve
(
__dirname
,
'files'
));
var
app
=
express
();
var
app
=
express
();
...
@@ -16,18 +20,23 @@ var router = new express.Router();
...
@@ -16,18 +20,23 @@ var router = new express.Router();
var
multipart
=
multipart
({
maxFieldsSize
:
2
*
1024
,
limit
:
'512mb'
,
timeout
:
3
*
60
*
1000
});
var
multipart
=
multipart
({
maxFieldsSize
:
2
*
1024
,
limit
:
'512mb'
,
timeout
:
3
*
60
*
1000
});
router
.
get
(
'/api/files/*'
,
files
.
get
);
router
.
get
(
'/api/files/*'
,
auth
.
ldap
,
files
.
get
);
router
.
put
(
'/api/files/*'
,
multipart
,
files
.
put
);
router
.
put
(
'/api/files/*'
,
auth
.
ldap
,
multipart
,
files
.
put
);
router
.
delete
(
'/api/files/*'
,
files
.
del
);
router
.
delete
(
'/api/files/*'
,
auth
.
ldap
,
files
.
del
);
// healthcheck in case / does not serve up any file yet
// healthcheck in case / does not serve up any file yet
router
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
sendfile
(
path
.
join
(
__dirname
,
'/app/welcome.html'
));
});
router
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
sendfile
(
path
.
join
(
__dirname
,
'/app/welcome.html'
));
});
app
.
use
(
morgan
(
'dev'
));
app
.
use
(
morgan
(
'dev'
));
app
.
use
(
compression
());
app
.
use
(
compression
());
app
.
use
(
bodyParser
.
json
());
app
.
use
(
'/settings'
,
express
.
static
(
__dirname
+
'/app'
));
app
.
use
(
'/settings'
,
express
.
static
(
__dirname
+
'/app'
));
app
.
use
(
express
.
static
(
__dirname
+
'/files'
));
app
.
use
(
express
.
static
(
__dirname
+
'/files'
));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
());
app
.
use
(
cookieParser
());
app
.
use
(
session
({
secret
:
'surfin surfin'
}));
app
.
use
(
passport
.
initialize
());
app
.
use
(
passport
.
session
());
app
.
use
(
router
);
app
.
use
(
router
);
app
.
use
(
lastMile
());
app
.
use
(
lastMile
());
...
...
cli/actions.js
View file @
591ad40
...
@@ -44,6 +44,8 @@ function collectFiles(filesOrFolders) {
...
@@ -44,6 +44,8 @@ function collectFiles(filesOrFolders) {
}
}
function
login
(
server
)
{
function
login
(
server
)
{
if
(
server
[
server
.
length
-
1
]
===
'/'
)
server
=
server
.
slice
(
0
,
-
1
);
console
.
log
(
'Using server'
,
server
);
console
.
log
(
'Using server'
,
server
);
config
.
set
(
'server'
,
server
);
config
.
set
(
'server'
,
server
);
}
}
...
...
package.json
View file @
591ad40
...
@@ -23,13 +23,16 @@
...
@@ -23,13 +23,16 @@
"compression"
:
"^1.5.0"
,
"compression"
:
"^1.5.0"
,
"connect-lastmile"
:
"0.0.10"
,
"connect-lastmile"
:
"0.0.10"
,
"connect-timeout"
:
"^1.6.2"
,
"connect-timeout"
:
"^1.6.2"
,
"cookie-parser"
:
"^1.3.5"
,
"debug"
:
"^2.2.0"
,
"debug"
:
"^2.2.0"
,
"del"
:
"^1.2.0"
,
"del"
:
"^1.2.0"
,
"ejs"
:
"^2.3.1"
,
"ejs"
:
"^2.3.1"
,
"express"
:
"^4.12.4"
,
"express"
:
"^4.12.4"
,
"express-session"
:
"^1.11.3"
,
"mkdirp"
:
"^0.5.1"
,
"mkdirp"
:
"^0.5.1"
,
"morgan"
:
"^1.6.0"
,
"morgan"
:
"^1.6.0"
,
"multiparty"
:
"^4.1.2"
,
"multiparty"
:
"^4.1.2"
,
"passport"
:
"^0.2.2"
,
"safetydance"
:
"0.0.16"
,
"safetydance"
:
"0.0.16"
,
"superagent"
:
"^1.2.0"
,
"superagent"
:
"^1.2.0"
,
"underscore"
:
"^1.8.3"
"underscore"
:
"^1.8.3"
...
...
src/auth.js
0 → 100644
View file @
591ad40
'use strict'
;
var
passport
=
require
(
'passport'
),
LdapStrategy
=
require
(
'passport-ldapjs'
).
Strategy
;
var
LDAP_URL
=
process
.
env
.
LDAP_URL
;
var
LDAP_USERS_BASE_DN
=
process
.
env
.
LDAP_USERS_BASE_DN
;
if
(
LDAP_URL
&&
LDAP_USERS_BASE_DN
)
{
console
.
log
(
'Enable ldap auth'
);
exports
.
ldap
=
passport
.
authenticate
(
'ldap'
,
{
successReturnToOrRedirect
:
'/'
,
failureRedirect
:
'/login'
,
failureFlash
:
true
});
}
else
{
exports
.
ldap
=
function
(
req
,
res
,
next
)
{
console
.
log
(
'ldap auth disabled'
);
next
();
};
}
var
opts
=
{
server
:
{
url
:
LDAP_URL
,
},
base
:
LDAP_USERS_BASE_DN
,
search
:
{
filter
:
'(uid={{username}})'
,
attributes
:
[
'displayname'
,
'username'
,
'mail'
,
'uid'
],
scope
:
'sub'
},
uidTag
:
'uid'
,
usernameField
:
'username'
,
passwordField
:
'password'
,
};
passport
.
use
(
new
LdapStrategy
(
opts
,
function
(
profile
,
done
)
{
console
.
log
(
'ldap'
,
profile
);
done
(
null
,
profile
);
}));
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment