Suppress a logging statement most of the time

Most of the time, we don't expect incoming requests to have an authorization
header. So this statement gets printed a lot, and doesn't provide much useful
information. We already have a statement listing what type of
authentication/authorization is required by the endpoint, and other statements
indicating either that authorization was successful with a particular method or
was not successful at all.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175969652
This commit is contained in:
mountford 2017-11-16 08:52:06 -08:00 committed by jianglai
parent d840180f3a
commit 29913cf5bd

View file

@ -75,7 +75,9 @@ public class OAuthAuthenticationMechanism implements AuthenticationMechanism {
// OAuthService itself only looks at the first one anyway. // OAuthService itself only looks at the first one anyway.
String header = request.getHeader(AUTHORIZATION); String header = request.getHeader(AUTHORIZATION);
if ((header == null) || !header.startsWith(BEARER_PREFIX)) { if ((header == null) || !header.startsWith(BEARER_PREFIX)) {
logger.infofmt("missing or invalid authorization header"); if (header != null) {
logger.infofmt("invalid authorization header");
}
return AuthResult.create(NONE); return AuthResult.create(NONE);
} }
// Assume that, if a bearer token is found, it's what OAuthService will use to attempt // Assume that, if a bearer token is found, it's what OAuthService will use to attempt