Skip to content
Closed
Show file tree
Hide file tree
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
13 changes: 0 additions & 13 deletions app/controllers/idv/image_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def create
def image_upload_form
@image_upload_form ||= Idv::ApiImageUploadForm.new(
params,
liveness_checking_enabled: liveness_checking_enabled?,
service_provider: current_sp,
analytics: analytics,
uuid_prefix: current_sp&.app_id,
Expand All @@ -32,17 +31,5 @@ def image_upload_form
def store_encrypted_images?
IdentityConfig.store.encrypted_document_storage_enabled
end

def liveness_checking_enabled?
IdentityConfig.store.doc_auth_selfie_capture[:enabled]
end

def ial_context
@ial_context ||= IalContext.new(
ial: sp_session_ial,
service_provider: current_sp,
user: current_user,
)
end
end
end
26 changes: 3 additions & 23 deletions app/forms/idv/api_image_upload_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ class ApiImageUploadForm

validates_presence_of :front
validates_presence_of :back
validates_presence_of :selfie, if: :liveness_checking_enabled
validates_presence_of :document_capture_session

validate :validate_images
validate :validate_duplicate_images, if: :image_resubmission_check?
validate :limit_if_rate_limited

def initialize(params, service_provider:, analytics: nil,
uuid_prefix: nil, irs_attempts_api_tracker: nil, store_encrypted_images: false,
liveness_checking_enabled: false)
uuid_prefix: nil, irs_attempts_api_tracker: nil, store_encrypted_images: false)
@params = params
@service_provider = service_provider
@analytics = analytics
@readable = {}
@uuid_prefix = uuid_prefix
@irs_attempts_api_tracker = irs_attempts_api_tracker
@store_encrypted_images = store_encrypted_images
@liveness_checking_enabled = liveness_checking_enabled
end

def submit
Expand Down Expand Up @@ -54,7 +51,7 @@ def submit
private

attr_reader :params, :analytics, :service_provider, :form_response, :uuid_prefix,
:irs_attempts_api_tracker, :liveness_checking_enabled
:irs_attempts_api_tracker

def increment_rate_limiter!
return unless document_capture_session
Expand Down Expand Up @@ -83,11 +80,9 @@ def post_images_to_client
doc_auth_client.post_images(
front_image: front_image_bytes,
back_image: back_image_bytes,
selfie_image: liveness_checking_enabled ? selfie_image_bytes : nil,
image_source: image_source,
user_uuid: user_uuid,
uuid_prefix: uuid_prefix,
liveness_checking_enabled: liveness_checking_enabled,
)
end

Expand All @@ -110,10 +105,6 @@ def back_image_bytes
@back_image_bytes ||= back.read
end

def selfie_image_bytes
@selfie_image_bytes ||= selfie.read
end

def validate_pii_from_doc(client_response)
response = Idv::DocPiiForm.new(
pii: client_response.pii_from_doc,
Expand Down Expand Up @@ -210,10 +201,6 @@ def back
as_readable(:back)
end

def selfie
as_readable(:selfie)
end

def document_capture_session
@document_capture_session ||= DocumentCaptureSession.find_by(
uuid: document_capture_session_uuid,
Expand All @@ -233,12 +220,6 @@ def validate_images
type: :not_a_file
)
end
if selfie.is_a? DataUrlImage::InvalidUrlFormatError
errors.add(
:selfie, t('doc_auth.errors.not_a_file'),
type: :not_a_file
)
end
end

def validate_duplicate_images
Expand Down Expand Up @@ -391,8 +372,7 @@ def image_metadata
def add_costs(response)
Db::AddDocumentVerificationAndSelfieCosts.
new(user_id: user_id,
service_provider: service_provider,
liveness_checking_enabled: liveness_checking_enabled).
service_provider: service_provider).
call(response)
end

Expand Down
5 changes: 2 additions & 3 deletions app/services/db/add_document_verification_and_selfie_costs.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Db
class AddDocumentVerificationAndSelfieCosts
def initialize(user_id:, service_provider:, liveness_checking_enabled:)
def initialize(user_id:, service_provider:)
@service_provider = service_provider
@liveness_checking_enabled = liveness_checking_enabled
@user_id = user_id
end

Expand All @@ -14,7 +13,7 @@ def call(client_response)

private

attr_reader :service_provider, :user_id, :liveness_checking_enabled
attr_reader :service_provider, :user_id

def add_cost(token)
Db::SpCost::AddSpCost.call(service_provider, 2, token)
Expand Down
1 change: 0 additions & 1 deletion app/services/db/sp_cost/add_sp_cost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class SpCostTypeError < StandardError; end
aamva
acuant_front_image
acuant_back_image
acuant_selfie
acuant_result
lexis_nexis_resolution
lexis_nexis_address
Expand Down
4 changes: 1 addition & 3 deletions app/services/doc_auth/acuant/acuant_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def post_images(
back_image:,
image_source:,
user_uuid: nil,
uuid_prefix: nil,
selfie_image: nil,
liveness_checking_enabled: false
uuid_prefix: nil
)
document_response = create_document(image_source: image_source)
return document_response unless document_response.success?
Expand Down
21 changes: 4 additions & 17 deletions app/services/doc_auth/error_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ def initialize(config)
ID = :id
FRONT = :front
BACK = :back
SELFIE = :selfie
GENERAL = :general

ERROR_KEYS = [
ID,
FRONT,
BACK,
SELFIE,
GENERAL,
].to_set.freeze

Expand Down Expand Up @@ -64,9 +62,7 @@ def generate_doc_auth_errors(response_info)
image_metric_errors = get_image_metric_errors(response_info[:image_metrics])
return image_metric_errors.to_h unless image_metric_errors.empty?

liveness_enabled = response_info[:liveness_enabled]
alert_errors = get_error_messages(liveness_enabled, response_info)
alert_error_count += 1 if alert_errors.include?(SELFIE)
alert_errors = get_error_messages(response_info)

error = ''
side = nil
Expand Down Expand Up @@ -175,7 +171,7 @@ def get_image_metric_errors(processed_image_metrics)
error_result
end

def get_error_messages(liveness_enabled, response_info)
def get_error_messages(response_info)
errors = Hash.new { |hash, key| hash[key] = Set.new }

if response_info[:doc_auth_result] != 'Passed'
Expand All @@ -189,11 +185,6 @@ def get_error_messages(liveness_enabled, response_info)
end
end

portrait_match_results = response_info[:portrait_match_results] || {}
if liveness_enabled && portrait_match_results.dig(:FaceMatchResult) != 'Pass'
errors[SELFIE] << Errors::SELFIE_FAILURE
end

errors
end

Expand Down Expand Up @@ -224,12 +215,8 @@ def scan_for_unknown_alerts(response_info)
unknown_fail_count
end

def self.general_error(_liveness_enabled)
Errors::GENERAL_ERROR
end

def self.wrapped_general_error(liveness_enabled)
{ general: [ErrorGenerator.general_error(liveness_enabled)], hints: true }
def self.wrapped_general_error
{ general: [Errors::GENERAL_ERROR], hints: true }
end

def supported_country_codes
Expand Down
4 changes: 0 additions & 4 deletions app/services/doc_auth/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module Errors
MULTIPLE_BACK_ID_FAILURES = 'multiple_back_id_failures'
MULTIPLE_FRONT_ID_FAILURES = 'multiple_front_id_failures'
REF_CONTROL_NUMBER_CHECK = 'ref_control_number_check'
SELFIE_FAILURE = 'selfie_failure'
SEX_CHECK = 'sex_check'
VISIBLE_COLOR_CHECK = 'visible_color_check'
VISIBLE_PHOTO_CHECK = 'visible_photo_check'
Expand Down Expand Up @@ -67,7 +66,6 @@ module Errors
MULTIPLE_BACK_ID_FAILURES,
MULTIPLE_FRONT_ID_FAILURES,
REF_CONTROL_NUMBER_CHECK,
SELFIE_FAILURE,
SEX_CHECK,
VISIBLE_COLOR_CHECK,
VISIBLE_PHOTO_CHECK,
Expand Down Expand Up @@ -115,8 +113,6 @@ module Errors
MULTIPLE_FRONT_ID_FAILURES => { long_msg: MULTIPLE_FRONT_ID_FAILURES, field_msg: FALLBACK_FIELD_LEVEL, hints: true },
MULTIPLE_BACK_ID_FAILURES => { long_msg: MULTIPLE_BACK_ID_FAILURES, field_msg: FALLBACK_FIELD_LEVEL, hints: true },
GENERAL_ERROR => { long_msg: GENERAL_ERROR, field_msg: FALLBACK_FIELD_LEVEL, hints: true },
# Liveness, use general error for now
SELFIE_FAILURE => { long_msg: GENERAL_ERROR, field_msg: FALLBACK_FIELD_LEVEL, hints: false },
}
# rubocop:enable Layout/LineLength
end
Expand Down
4 changes: 0 additions & 4 deletions app/services/doc_auth/lexis_nexis/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module LexisNexis
:trueid_account_id,
:trueid_noliveness_cropping_workflow,
:trueid_noliveness_nocropping_workflow,
:trueid_liveness_cropping_workflow,
:trueid_liveness_nocropping_workflow,
:trueid_password,
:trueid_username,
:hmac_key_id,
Expand All @@ -25,8 +23,6 @@ module LexisNexis
:request_mode,
:trueid_noliveness_cropping_workflow,
:trueid_noliveness_nocropping_workflow,
:trueid_liveness_cropping_workflow,
:trueid_liveness_nocropping_workflow,
:locale,
:dpi_threshold,
:sharpness_threshold,
Expand Down
6 changes: 1 addition & 5 deletions app/services/doc_auth/lexis_nexis/lexis_nexis_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ def create_document
def post_images(
front_image:,
back_image:,
selfie_image: nil,
image_source: nil,
user_uuid: nil,
uuid_prefix: nil,
liveness_checking_enabled: false
uuid_prefix: nil
)
Requests::TrueIdRequest.new(
config: config,
user_uuid: user_uuid,
uuid_prefix: uuid_prefix,
front_image: front_image,
back_image: back_image,
selfie_image: selfie_image,
image_source: image_source,
liveness_checking_required: liveness_checking_enabled,
).fetch
end
end
Expand Down
25 changes: 5 additions & 20 deletions app/services/doc_auth/lexis_nexis/requests/true_id_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ module DocAuth
module LexisNexis
module Requests
class TrueIdRequest < DocAuth::LexisNexis::Request
attr_reader :front_image, :back_image, :selfie_image, :liveness_checking_required
attr_reader :front_image, :back_image

def initialize(
config:,
user_uuid:,
uuid_prefix:,
front_image:,
back_image:,
selfie_image: nil,
image_source: nil,
liveness_checking_required: false
image_source: nil
)
super(config: config, user_uuid: user_uuid, uuid_prefix: uuid_prefix)
@front_image = front_image
@back_image = back_image
@selfie_image = selfie_image
@image_source = image_source
# when set to required, be sure to pass in selfie_image
@liveness_checking_required = liveness_checking_required
end

private
Expand All @@ -30,18 +25,16 @@ def body
Document: {
Front: encode(front_image),
Back: encode(back_image),
Selfie: (encode(selfie_image) if include_liveness?),
DocumentType: 'DriversLicense',
},
}.compact
}

settings.merge(document).to_json
end

def handle_http_response(http_response)
LexisNexis::Responses::TrueIdResponse.new(
http_response,
liveness_checking_required,
config,
)
end
Expand All @@ -64,13 +57,9 @@ def password

def workflow
if acuant_sdk_source?
include_liveness? ?
config.trueid_liveness_nocropping_workflow :
config.trueid_noliveness_nocropping_workflow
config.trueid_noliveness_nocropping_workflow
else
include_liveness? ?
config.trueid_liveness_cropping_workflow :
config.trueid_noliveness_cropping_workflow
config.trueid_noliveness_cropping_workflow
end
end

Expand All @@ -89,10 +78,6 @@ def metric_name
def timeout
IdentityConfig.store.lexisnexis_trueid_timeout
end

def include_liveness?
liveness_checking_required
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class TrueIdResponse < DocAuth::Response
}.freeze
attr_reader :config, :http_response

def initialize(http_response, config, liveness_checking_enabled = false)
def initialize(http_response, config)
@config = config
@http_response = http_response
@liveness_checking_enabled = liveness_checking_enabled

super(
success: successful_result?,
errors: error_messages,
Expand All @@ -74,7 +74,7 @@ def error_messages
if true_id_product&.dig(:AUTHENTICATION_RESULT).present?
ErrorGenerator.new(config).generate_doc_auth_errors(response_info)
elsif true_id_product.present?
ErrorGenerator.wrapped_general_error(@liveness_checking_enabled)
ErrorGenerator.wrapped_general_error
else
{ network: true } # return a generic technical difficulties error to user
end
Expand Down
4 changes: 1 addition & 3 deletions app/services/doc_auth/mock/doc_auth_mock_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ def post_back_image(image:, instance_id:)
def post_images(
front_image:,
back_image:,
selfie_image: nil,
image_source: nil,
user_uuid: nil,
uuid_prefix: nil,
liveness_checking_enabled: false
uuid_prefix: nil
)
return mocked_response_for_method(__method__) if method_mocked?(__method__)

Expand Down
Loading