-
Notifications
You must be signed in to change notification settings - Fork 1
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 #389: SCA passes even though iProov failed #390
Changes from 4 commits
8fb0565
7933f33
41cd9e3
aa3a41d
ff520da
f3150ca
9700036
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,29 +20,27 @@ | |
import com.wultra.app.enrollmentserver.api.model.onboarding.response.OtpVerifyResponse; | ||
import com.wultra.app.enrollmentserver.model.enumeration.*; | ||
import com.wultra.app.enrollmentserver.model.integration.OwnerId; | ||
import com.wultra.app.onboardingserver.common.database.IdentityVerificationRepository; | ||
import com.wultra.app.onboardingserver.common.database.OnboardingOtpRepository; | ||
import com.wultra.app.onboardingserver.common.database.OnboardingProcessRepository; | ||
import com.wultra.app.onboardingserver.common.database.entity.IdentityVerificationEntity; | ||
import com.wultra.app.onboardingserver.common.database.entity.OnboardingOtpEntity; | ||
import com.wultra.app.onboardingserver.common.database.entity.OnboardingProcessEntity; | ||
import com.wultra.app.onboardingserver.common.enumeration.OnboardingProcessError; | ||
import com.wultra.app.onboardingserver.common.errorhandling.OnboardingProcessException; | ||
import com.wultra.app.onboardingserver.common.service.OnboardingProcessLimitService; | ||
import com.wultra.app.onboardingserver.configuration.IdentityVerificationConfig; | ||
import com.wultra.app.onboardingserver.common.database.IdentityVerificationRepository; | ||
import com.wultra.app.onboardingserver.common.database.entity.IdentityVerificationEntity; | ||
import com.wultra.app.onboardingserver.errorhandling.OnboardingOtpDeliveryException; | ||
import com.wultra.app.onboardingserver.errorhandling.OnboardingProviderException; | ||
import com.wultra.app.onboardingserver.provider.OnboardingProvider; | ||
import com.wultra.app.onboardingserver.provider.model.request.SendOtpCodeRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.i18n.LocaleContextHolder; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Date; | ||
import java.util.Optional; | ||
|
||
import static com.wultra.app.enrollmentserver.model.enumeration.IdentityVerificationPhase.PRESENCE_CHECK; | ||
|
||
|
@@ -182,13 +180,12 @@ private OtpVerifyResponse verifyPresenceCheck(final OnboardingProcessEntity proc | |
final String rejectReason = idVerification.getRejectReason(); | ||
final RejectOrigin rejectOrigin = idVerification.getRejectOrigin(); | ||
|
||
if (errorOrigin == ErrorOrigin.PRESENCE_CHECK && StringUtils.isNotBlank(errorDetail) | ||
|| rejectOrigin == RejectOrigin.PRESENCE_CHECK && StringUtils.isNotBlank(rejectReason)) { | ||
if (errorOrigin == ErrorOrigin.PRESENCE_CHECK || rejectOrigin == RejectOrigin.PRESENCE_CHECK) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure whether this is a permanent or temporary change. When we called iProov validate before verification, the reject reason was |
||
logger.info("SCA failed, identity verification ID: {} of process ID: {} contains errorDetail: {}, rejectReason: {} from previous step", | ||
idVerification.getId(), processId, errorDetail, rejectReason); | ||
return moveToPhasePresenceCheck(process, response, idVerification); | ||
} else { | ||
logger.debug("PRESENCE_CHECK without error or reject reason, process ID: {}", idVerification.getProcessId()); | ||
logger.debug("PRESENCE_CHECK without error or reject origin, process ID: {}", idVerification.getProcessId()); | ||
} | ||
return response; | ||
} | ||
|
@@ -244,19 +241,10 @@ private void markVerificationOtpAsFailed(String processId) throws OnboardingProc | |
* @throws OnboardingOtpDeliveryException Thrown when OTP code could not be sent. | ||
*/ | ||
private void sendOtpCode(String processId, boolean isResend) throws OnboardingProcessException, OnboardingOtpDeliveryException { | ||
final Optional<OnboardingProcessEntity> processOptional = onboardingProcessRepository.findById(processId); | ||
if (processOptional.isEmpty()) { | ||
logger.warn("Onboarding process not found: {}", processId); | ||
throw new OnboardingProcessException(); | ||
} | ||
final OnboardingProcessEntity process = processOptional.get(); | ||
// Create an OTP code | ||
final String otpCode; | ||
if (isResend) { | ||
otpCode = otpService.createOtpCodeForResend(process, OtpType.USER_VERIFICATION); | ||
} else { | ||
otpCode = otpService.createOtpCode(process, OtpType.USER_VERIFICATION); | ||
} | ||
final OnboardingProcessEntity process = onboardingProcessRepository.findById(processId).orElseThrow(() -> | ||
new OnboardingProcessException("Onboarding process not found: " + processId)); | ||
|
||
final String otpCode = createOtpCode(isResend, process); | ||
// Send the OTP code | ||
try { | ||
final SendOtpCodeRequest request = SendOtpCodeRequest.builder() | ||
|
@@ -274,4 +262,11 @@ private void sendOtpCode(String processId, boolean isResend) throws OnboardingPr | |
} | ||
} | ||
|
||
private String createOtpCode(final boolean isResend, final OnboardingProcessEntity process) throws OnboardingOtpDeliveryException, OnboardingProcessException { | ||
if (isResend) { | ||
return otpService.createOtpCodeForResend(process, OtpType.USER_VERIFICATION); | ||
} else { | ||
return otpService.createOtpCode(process, OtpType.USER_VERIFICATION); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import com.wultra.app.onboardingserver.statemachine.action.clientevaluation.ClientEvaluationInitAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.otp.OtpVerificationResendAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.otp.OtpVerificationSendAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.presencecheck.MoveToPresenceCheckVerificationPendingAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.presencecheck.PresenceCheckInitAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.presencecheck.PresenceCheckNotInitializedAction; | ||
import com.wultra.app.onboardingserver.statemachine.action.presencecheck.PresenceCheckVerificationAction; | ||
|
@@ -81,6 +82,8 @@ public class StateMachineConfig extends EnumStateMachineConfigurerAdapter<Onboar | |
|
||
private final PresenceCheckVerificationAction presenceCheckVerificationAction; | ||
|
||
private final MoveToPresenceCheckVerificationPendingAction moveToPresenceCheckVerificationPendingAction; | ||
|
||
private final MoveToDocumentUploadVerificationPendingAction moveToDocumentUploadVerificationPendingAction; | ||
|
||
private final DocumentsVerificationPendingGuard documentsVerificationPendingGuard; | ||
|
@@ -117,6 +120,7 @@ public StateMachineConfig( | |
final PresenceCheckInitAction presenceCheckInitAction, | ||
final PresenceCheckNotInitializedAction presenceCheckNotInitializedAction, | ||
final PresenceCheckVerificationAction presenceCheckVerificationAction, | ||
final MoveToPresenceCheckVerificationPendingAction moveToPresenceCheckVerificationPendingAction, | ||
final MoveToDocumentUploadVerificationPendingAction moveToDocumentUploadVerificationPendingAction, | ||
final DocumentsVerificationPendingGuard documentsVerificationPendingGuard, | ||
final VerificationDocumentStartAction verificationDocumentStartAction, | ||
|
@@ -140,6 +144,7 @@ public StateMachineConfig( | |
this.presenceCheckNotInitializedAction = presenceCheckNotInitializedAction; | ||
this.presenceCheckVerificationAction = presenceCheckVerificationAction; | ||
|
||
this.moveToPresenceCheckVerificationPendingAction = moveToPresenceCheckVerificationPendingAction; | ||
this.moveToDocumentUploadVerificationPendingAction = moveToDocumentUploadVerificationPendingAction; | ||
this.documentsVerificationPendingGuard = documentsVerificationPendingGuard; | ||
this.verificationDocumentStartAction = verificationDocumentStartAction; | ||
|
@@ -329,14 +334,21 @@ private void configurePresenceCheckTransitions(StateMachineTransitionConfigurer< | |
.and() | ||
.withExternal() | ||
.source(OnboardingState.PRESENCE_CHECK_IN_PROGRESS) | ||
.event(OnboardingEvent.EVENT_NEXT_STATE) | ||
.event(OnboardingEvent.PRESENCE_CHECK_SUBMITTED) | ||
.action(moveToPresenceCheckVerificationPendingAction) | ||
.target(OnboardingState.PRESENCE_CHECK_VERIFICATION_PENDING) | ||
|
||
.and() | ||
.withExternal() | ||
.source(OnboardingState.PRESENCE_CHECK_VERIFICATION_PENDING) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kober32 You may expect |
||
.action(presenceCheckVerificationAction) | ||
.event(OnboardingEvent.EVENT_NEXT_STATE) | ||
.target(OnboardingState.CHOICE_PRESENCE_CHECK_PROCESSING) | ||
|
||
.and() | ||
.withChoice() | ||
.source(OnboardingState.CHOICE_PRESENCE_CHECK_PROCESSING) | ||
.first(OnboardingState.PRESENCE_CHECK_IN_PROGRESS, statusInProgressGuard) | ||
.first(OnboardingState.PRESENCE_CHECK_VERIFICATION_PENDING, statusInProgressGuard) | ||
.then(OnboardingState.OTP_VERIFICATION_PENDING, | ||
context -> otpVerificationEnabledGuard.evaluate(context) && statusAcceptedGuard.evaluate(context), | ||
otpVerificationSendAction | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kober32 A new endpoint.