Fix bug in authentication code

[] changed RequestHandler to log a warning instead of returning an error to the user when authentication failed. Unfortunately, it didn't handle the resulting absent value of AuthResult. I don't yet know why the tests pass, and plan to add a test to check for this situation, but I wanted to start by fixing the problem as soon as possible, as it seems like this would result in exceptions any time a request was handled which didn't pass authentication.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149136265
This commit is contained in:
mountford 2017-03-03 11:47:03 -08:00 committed by Ben McIlwain
parent 9a15f08b3a
commit 034312c17d

View file

@ -173,6 +173,7 @@ public class RequestHandler<C> {
if (!authResult.isPresent()) { if (!authResult.isPresent()) {
logger.warning("Request would not have been authorized"); logger.warning("Request would not have been authorized");
// TODO(b/28219927): Change this to call rsp.sendError(SC_FORBIDDEN) and return // TODO(b/28219927): Change this to call rsp.sendError(SC_FORBIDDEN) and return
authResult = Optional.of(AuthResult.NOT_AUTHENTICATED);
} }
// Build a new request component using any modules we've constructed by this point. // Build a new request component using any modules we've constructed by this point.