Unverified Commit 648a75e0 authored by reshmi-nair's avatar reshmi-nair Committed by GitHub
Browse files

SB-26327 Onboarding breakdown (#923)

Showing with 13 additions and 0 deletions
+13 -0
......@@ -53,6 +53,9 @@ public class OnRequestHandler implements ActionCreator {
request.getHeaders();
CompletionStage<Result> result = checkForServiceHealth(request);
if (result != null) return result;
logger.info("**learner request :"+request);
logger.info("**learner request header :"+request.getHeaders().toMap());
logger.info("**learner request body :"+request.body().asJson());
// From 3.0.0 checking user access-token and managed-by from the request header
Map userAuthentication = RequestInterceptor.verifyRequestData(request);
String message = (String) userAuthentication.get(JsonKey.USER_ID);
......
......@@ -131,6 +131,7 @@ public class RequestInterceptor {
// The API must be invoked with either access token or client token.
if (accessToken.isPresent()) {
clientId = AccessTokenValidator.verifyUserToken(accessToken.get());
logger.info("**learner accesstoken verified :" + clientId);
if (!JsonKey.USER_UNAUTH_STATES.contains(clientId)) {
// Now we have some valid token, next verify if the token is matching the request.
String requestedForUserID = getUserRequestedFor(request);
......@@ -148,11 +149,13 @@ public class RequestInterceptor {
} else {
clientId = JsonKey.UNAUTHORIZED;
}
logger.info("**learner managed accesstoken verified :" + clientId);
}
} else {
logger.debug("Ignoring x-authenticated-for token...");
}
}
logger.info("**learner added userid to userAuthentication :" + clientId);
userAuthentication.put(JsonKey.USER_ID, clientId);
userAuthentication.put(JsonKey.MANAGED_FOR, managedForId);
}
......@@ -175,6 +178,7 @@ public class RequestInterceptor {
userAuthentication.put(JsonKey.USER_ID, JsonKey.ANONYMOUS);
}
}
logger.info("**learner userAuthentication :" + userAuthentication.toString());
return userAuthentication;
}
......
......@@ -25,12 +25,15 @@ public class AccessTokenValidator {
Map<Object, Object> headerData =
mapper.readValue(new String(decodeFromBase64(header)), Map.class);
String keyId = headerData.get("kid").toString();
logger.info("**learner calling accesstoken verifyRSASign()");
boolean isValid =
CryptoUtil.verifyRSASign(
payLoad,
decodeFromBase64(signature),
KeyManager.getPublicKey(keyId).getPublicKey(),
JsonKey.SHA_256_WITH_RSA);
logger.info("**learner accesstoken verifyRSASign() :" + isValid);
if (isValid) {
Map<String, Object> tokenBody =
mapper.readValue(new String(decodeFromBase64(body)), Map.class);
......@@ -38,6 +41,7 @@ public class AccessTokenValidator {
if (isExp) {
return Collections.EMPTY_MAP;
}
logger.info("**learner accesstoken validated token tokenBody :" + tokenBody);
return tokenBody;
}
return Collections.EMPTY_MAP;
......@@ -86,6 +90,8 @@ public class AccessTokenValidator {
String userId = JsonKey.UNAUTHORIZED;
try {
Map<String, Object> payload = validateToken(token);
logger.info("learner accesstoken validateToken() :" + payload.toString());
if (MapUtils.isNotEmpty(payload) && checkIss((String) payload.get("iss"))) {
userId = (String) payload.get(JsonKey.SUB);
if (StringUtils.isNotBlank(userId)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment