Skip to content

Commit

Permalink
Merge pull request #526 from joola/feature/#515
Browse files Browse the repository at this point in the history
#515 basic auth opt-in and disable on http.
  • Loading branch information
itayw committed Jun 2, 2014
2 parents 9e00292 + c05c1e0 commit 4d45185
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ services:
- mongodb
- rabbitmq

env:
JOOLAIO_CONFIG_AUTHENTICATION_BASICAUTH_ENABLED=TRUE

#branches:
# only:
# - master
Expand Down
4 changes: 3 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.0.90
version: 0.0.95
interfaces:
webserver:
enabled: true
Expand Down Expand Up @@ -65,6 +65,8 @@ store:
dispatch:
expires: 60
authentication:
basicauth:
enabled: false
tokens:
expireafter: 1200000
ratelimits:
Expand Down
14 changes: 13 additions & 1 deletion lib/dispatch/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,20 @@ exports.authenticate = {
callback = callback || function () {
};

var err;
if (!joola.config.get('authentication:basicauth').enabled) {
err = new Error('Forbidden');
err.code = 403;
return callback(err);
}
else if (joola.webserver.http && joola.config.get('authentication:basicauth').enabled) {
err = new Error('Forbidden');
err.code = 403;
return callback(err);
}

if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
err = new Error('Forbidden');
err.code = 403;
return callback(err);
}
Expand Down

0 comments on commit 4d45185

Please sign in to comment.