Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowing (custom) authorization to occur even when user login is not logged in #304

Merged
merged 3 commits into from
May 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,31 @@ var getRouter = exports.getRouter = function(options, cb) {
return unauthorized(res);
}
}

//authentication passed, now allow app to authorize the request
if (authRule.authorizeRequired) {
req.authRule = authRule;
return options.authorize(req, res,
completeRequest,

//the error/unauthorized case...
function(err) {
logger.warn({category: 'auth', message: 'unauthorized access attempt; url: ' + req.url + '; app auth error message: ' + (err || 'no_error_message_provided')});

if (authRule.redirectUrlUnauthorized) {
//send the user back to redirectUrlUnauthorized
req.url = authRule.redirectUrlUnauthorized;
delete req.isFeatherPage;
return next();
}

//no app configured redirect URL, just return a 403
return forbidden(res);
}

//authentication passed, now allow app to authorize the request
if (authRule.authorizeRequired) {
req.authRule = authRule;
return options.authorize(req, res,
completeRequest,

//the error/unauthorized case...
function(err) {
logger.warn({category: 'auth', message: 'unauthorized access attempt; url: ' + req.url + '; app auth error message: ' + (err || 'no_error_message_provided')});

if (authRule.redirectUrlUnauthorized) {
//send the user back to redirectUrlUnauthorized
req.url = authRule.redirectUrlUnauthorized;
delete req.isFeatherPage;
return next();
}
);
} else {
return completeRequest();
}

//no app configured redirect URL, just return a 403
return forbidden(res);
}
);
} else {
return completeRequest();
}
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ Date.fromArray = function(array) {
}
return null;
};