[resolve #9084] - Log more information in adapter-core module (#9086)

Co-authored-by: Stian Thorgersen <stianst@gmail.com>
This commit is contained in:
Marcin Niedzielski 2022-08-26 15:25:21 +02:00 committed by GitHub
parent c968925298
commit 5dbbc0e7bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -51,6 +51,7 @@ public class BasicAuthRequestAuthenticator extends BearerTokenRequestAuthenticat
public AuthOutcome authenticate(HttpFacade exchange) { public AuthOutcome authenticate(HttpFacade exchange) {
List<String> authHeaders = exchange.getRequest().getHeaders("Authorization"); List<String> authHeaders = exchange.getRequest().getHeaders("Authorization");
if (authHeaders == null || authHeaders.isEmpty()) { if (authHeaders == null || authHeaders.isEmpty()) {
log.debug("Authorization header not present");
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_AUTHORIZATION_HEADER, null, null); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_AUTHORIZATION_HEADER, null, null);
return AuthOutcome.NOT_ATTEMPTED; return AuthOutcome.NOT_ATTEMPTED;
} }
@ -64,6 +65,7 @@ public class BasicAuthRequestAuthenticator extends BearerTokenRequestAuthenticat
} }
if (tokenString == null) { if (tokenString == null) {
log.debug("Token is not present in Authorization header");
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.INVALID_TOKEN, null, null); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.INVALID_TOKEN, null, null);
return AuthOutcome.NOT_ATTEMPTED; return AuthOutcome.NOT_ATTEMPTED;
} }

View file

@ -64,6 +64,7 @@ public class BearerTokenRequestAuthenticator {
public AuthOutcome authenticate(HttpFacade exchange) { public AuthOutcome authenticate(HttpFacade exchange) {
List<String> authHeaders = exchange.getRequest().getHeaders("Authorization"); List<String> authHeaders = exchange.getRequest().getHeaders("Authorization");
if (authHeaders == null || authHeaders.isEmpty()) { if (authHeaders == null || authHeaders.isEmpty()) {
log.debug("Authorization header not present");
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_BEARER_TOKEN, null, null); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_BEARER_TOKEN, null, null);
return AuthOutcome.NOT_ATTEMPTED; return AuthOutcome.NOT_ATTEMPTED;
} }
@ -81,6 +82,7 @@ public class BearerTokenRequestAuthenticator {
} }
if (tokenString == null) { if (tokenString == null) {
log.debug("Token is not present in Authorization header");
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_BEARER_TOKEN, null, null); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_BEARER_TOKEN, null, null);
return AuthOutcome.NOT_ATTEMPTED; return AuthOutcome.NOT_ATTEMPTED;
} }
@ -102,7 +104,7 @@ public class BearerTokenRequestAuthenticator {
try { try {
token = AdapterTokenVerifier.verifyToken(tokenString, deployment); token = AdapterTokenVerifier.verifyToken(tokenString, deployment);
} catch (VerificationException e) { } catch (VerificationException e) {
log.debug("Failed to verify token"); log.debugf("Failed to verify token: %s", e.getMessage());
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.INVALID_TOKEN, "invalid_token", e.getMessage()); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.INVALID_TOKEN, "invalid_token", e.getMessage());
return AuthOutcome.FAILED; return AuthOutcome.FAILED;
} }

View file

@ -41,6 +41,7 @@ public class QueryParameterTokenRequestAuthenticator extends BearerTokenRequestA
tokenString = null; tokenString = null;
tokenString = getAccessTokenFromQueryParameter(exchange); tokenString = getAccessTokenFromQueryParameter(exchange);
if (tokenString == null || tokenString.trim().isEmpty()) { if (tokenString == null || tokenString.trim().isEmpty()) {
log.debug("Token is not present in query");
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_QUERY_PARAMETER_ACCESS_TOKEN, null, null); challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_QUERY_PARAMETER_ACCESS_TOKEN, null, null);
return AuthOutcome.NOT_ATTEMPTED; return AuthOutcome.NOT_ATTEMPTED;
} }