Skip to content

Commit

Permalink
Unsetting default value of version, changing occurrences of "all"
Browse files Browse the repository at this point in the history
… to `const all`
  • Loading branch information
avoidwork committed Dec 20, 2016
1 parent 53f07dd commit e4be1b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Tenso {
});
this.server.tenso = this;
this.websocket = null;
this.version = "4.0.0";
this.version = "";
}

error (req, res, err) {
Expand Down
43 changes: 22 additions & 21 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const path = require("path"),
OAuth2Strategy = require("passport-oauth2").Strategy,
SAMLStrategy = require("passport-saml").Strategy,
TwitterStrategy = require("passport-twitter").Strategy,
RedisStore = require("connect-redis")(session);
RedisStore = require("connect-redis")(session),
all = "all";

let uws, coap;

Expand All @@ -45,10 +46,10 @@ function escape (arg) {
return arg.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
}

function capitalize (obj, all = false) {
function capitalize (obj, every = false) {
let result;

if (all) {
if (every) {
result = explode(obj, " ").map(capitalize).join(" ");
} else {
result = obj.charAt(0).toUpperCase() + obj.slice(1);
Expand Down Expand Up @@ -87,20 +88,20 @@ function auth (obj, config) {

function init (sess) {
passportInit = passport.initialize();
obj.server.use(passportInit, "all").blacklist(passportInit);
obj.server.use(passportInit, all).blacklist(passportInit);

if (sess) {
passportSession = passport.session();
obj.server.use(passportSession, "all").blacklist(passportSession);
obj.server.use(passportSession, all).blacklist(passportSession);
}
}

function redirect (req, res) {
res.redirect(config.auth.redirect);
}

obj.server.use(middleware.decorate, "all").blacklist(middleware.decorate);
obj.server.use(middleware.parse, "all").blacklist(middleware.parse);
obj.server.use(middleware.decorate, all).blacklist(middleware.decorate);
obj.server.use(middleware.parse, all).blacklist(middleware.parse);
obj.server.blacklist(middleware.asyncFlag);

config.auth.protect = (config.auth.protect || []).map(i => {
Expand All @@ -127,7 +128,7 @@ function auth (obj, config) {
authUris.push("/login");
}

obj.server.use(middleware.valid, "all").blacklist(middleware.valid);
obj.server.use(middleware.valid, all).blacklist(middleware.valid);

if (stateful) {
sesh = {
Expand All @@ -144,43 +145,43 @@ function auth (obj, config) {
fnCookie = cookie();
fnSession = session(sesh);

obj.server.use(fnSession, "all").blacklist(fnSession);
obj.server.use(fnCookie, "all").blacklist(fnCookie);
obj.server.use(middleware.bypass, "all").blacklist(middleware.bypass);
obj.server.use(fnSession, all).blacklist(fnSession);
obj.server.use(fnCookie, all).blacklist(fnCookie);
obj.server.use(middleware.bypass, all).blacklist(middleware.bypass);

if (config.security.csrf) {
luscaCsrf = lusca.csrf({key: config.security.key, secret: config.security.secret});
obj.server.use(csrfWrapper, "all").blacklist(csrfWrapper);
obj.server.use(csrfWrapper, all).blacklist(csrfWrapper);
}
}

if (config.security.csp instanceof Object) {
luscaCsp = lusca.csp(config.security.csp);
obj.server.use(luscaCsp, "all").blacklist(luscaCsp);
obj.server.use(luscaCsp, all).blacklist(luscaCsp);
}

if (!isEmpty(config.security.xframe || "")) {
luscaXframe = lusca.xframe(config.security.xframe);
obj.server.use(luscaXframe, "all").blacklist(luscaXframe);
obj.server.use(luscaXframe, all).blacklist(luscaXframe);
}

if (!isEmpty(config.security.p3p || "")) {
luscaP3p = lusca.p3p(config.security.p3p);
obj.server.use(luscaP3p, "all").blacklist(luscaP3p);
obj.server.use(luscaP3p, all).blacklist(luscaP3p);
}

if (config.security.hsts instanceof Object) {
luscaHsts = lusca.hsts(config.security.hsts);
obj.server.use(luscaHsts, "all").blacklist(luscaHsts);
obj.server.use(luscaHsts, all).blacklist(luscaHsts);
}

if (config.security.xssProtection instanceof Object) {
luscaXssProtection = lusca.xssProtection(config.security.xssProtection);
obj.server.use(luscaXssProtection, "all").blacklist(luscaXssProtection);
obj.server.use(luscaXssProtection, all).blacklist(luscaXssProtection);
}

// Can fork to `middleware.keymaster()`
obj.server.use(middleware.zuul, "all").blacklist(middleware.zuul);
obj.server.use(middleware.zuul, all).blacklist(middleware.zuul);

if (stateless && !stateful) {
init(false);
Expand Down Expand Up @@ -210,7 +211,7 @@ function auth (obj, config) {
});

r = r.replace(/\|$/, "") + ")).*$";
obj.server.use(r, middleware.guard, "all").blacklist(middleware.guard);
obj.server.use(r, middleware.guard, all).blacklist(middleware.guard);
}());

config.routes.get["/login"] = config.auth.local.enabled ? keys ? {
Expand Down Expand Up @@ -270,7 +271,7 @@ function auth (obj, config) {
obj.server.get("/auth/basic", passportAuth).blacklist(passportAuth);
obj.server.get("/auth/basic", redirect);
} else {
obj.server.use(passportAuth, "all").blacklist(passportAuth);
obj.server.use(passportAuth, all).blacklist(passportAuth);
}
}());
}
Expand Down Expand Up @@ -305,7 +306,7 @@ function auth (obj, config) {
obj.server.get("/auth/bearer", passportAuth).blacklist(passportAuth);
obj.server.get("/auth/bearer", redirect);
} else {
obj.server.use(passportAuth, "all").blacklist(passportAuth);
obj.server.use(passportAuth, all).blacklist(passportAuth);
}
}());
}
Expand Down

0 comments on commit e4be1b0

Please sign in to comment.