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')); }