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

Fix #904: Add parsed user agent to the audit #909

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.wultra.app.enrollmentserver.errorhandling.MobileTokenConfigurationException;
import com.wultra.app.enrollmentserver.errorhandling.MobileTokenException;
import com.wultra.app.enrollmentserver.impl.service.converter.MobileTokenConverter;
import com.wultra.core.http.common.headers.UserAgent;
import com.wultra.core.http.common.request.RequestContext;
import com.wultra.security.powerauth.client.PowerAuthClient;
import com.wultra.security.powerauth.client.model.enumeration.SignatureType;
Expand Down Expand Up @@ -64,7 +65,7 @@ public class MobileTokenService {
private static final String ATTR_AUTH_FACTOR = "authFactor";
private static final String ATTR_REJECT_REASON = "rejectReason";
private static final String PROXIMITY_OTP = "proximity_otp";

private static final String DEVICE = "device";
private final PowerAuthClient powerAuthClient;
private final MobileTokenConverter mobileTokenConverter;
private final OperationTemplateService operationTemplateService;
Expand Down Expand Up @@ -165,6 +166,10 @@ public Response operationApprove(@NotNull final OperationApproveParameterObject
approveRequest.getAdditionalData().put(ATTR_IP_ADDRESS, request.getRequestContext().getIpAddress());
approveRequest.getAdditionalData().put(ATTR_USER_AGENT, request.getRequestContext().getUserAgent());
approveRequest.getAdditionalData().put(ATTR_AUTH_FACTOR, request.getSignatureFactors().toString());
final UserAgent.Device device = UserAgent.parse(request.getRequestContext().getUserAgent());
if (device != null) {
approveRequest.getAdditionalData().put(DEVICE, device);
}

if (request.getProximityCheckOtp() != null) {
approveRequest.getAdditionalData().put(PROXIMITY_OTP, request.getProximityCheckOtp());
Expand Down Expand Up @@ -200,6 +205,10 @@ public void operationFailApprove(@NotNull String operationId, @NotNull RequestCo
// Prepare additional data
request.getAdditionalData().put(ATTR_IP_ADDRESS, requestContext.getIpAddress());
request.getAdditionalData().put(ATTR_USER_AGENT, requestContext.getUserAgent());
final UserAgent.Device device = UserAgent.parse(requestContext.getUserAgent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of the scope of this PR, but UserAgent.parse is missing Javadoc, and instead of null it could return Optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (device != null) {
request.getAdditionalData().put(DEVICE, device);
}

final OperationUserActionResponse failApprovalResponse = powerAuthClient.failApprovalOperation(
request,
Expand Down Expand Up @@ -250,6 +259,10 @@ public Response operationReject(
rejectRequest.getAdditionalData().put(ATTR_IP_ADDRESS, requestContext.getIpAddress());
rejectRequest.getAdditionalData().put(ATTR_USER_AGENT, requestContext.getUserAgent());
rejectRequest.getAdditionalData().put(ATTR_REJECT_REASON, rejectReason);
final UserAgent.Device device = UserAgent.parse(requestContext.getUserAgent());
if (device != null) {
rejectRequest.getAdditionalData().put(DEVICE, device);
}

final OperationUserActionResponse rejectResponse = powerAuthClient.operationReject(
rejectRequest,
Expand Down
Loading