From 4c69af5ae217ec9aa044dc7ddf54c343ab3c32f2 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Fri, 6 Dec 2013 12:00:18 -0800 Subject: [PATCH 1/2] Add Model.requireToken, default swagger to false --- lib/application.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 51896c9a..028fb53a 100644 --- a/lib/application.js +++ b/lib/application.js @@ -186,7 +186,10 @@ app.enableAuth = function() { } } ); - } else if(method.fn && method.fn.requireToken === false) { + } else if( + Model.requireToken === false || + method.fn && method.fn.requireToken === false + ) { next(); } else { var e = new Error('Access Denied'); @@ -282,6 +285,14 @@ app.boot = function(options) { } } + // disable token requirement for swagger, if available + var swagger = app.remotes().exports.swagger; + var requireTokenForSwagger = appConfig.swagger + && appConfig.swagger.requireToken; + if(swagger) { + swagger.requireToken = requireTokenForSwagger || false; + } + // require directories var requiredModels = requireDir(path.join(appRootDir, 'models')); } From bc27f074724592ca3837b8dc4646bbc8e31079cf Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Fri, 6 Dec 2013 12:09:52 -0800 Subject: [PATCH 2/2] Add Model.requireToken for disabling token requirement --- lib/application.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/application.js b/lib/application.js index 028fb53a..7089d909 100644 --- a/lib/application.js +++ b/lib/application.js @@ -188,6 +188,7 @@ app.enableAuth = function() { ); } else if( Model.requireToken === false || + Model.settings.requireToken === false || method.fn && method.fn.requireToken === false ) { next();