-
Notifications
You must be signed in to change notification settings - Fork 66
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
Rc vebt 777 revised - draft PR #19580
Changes from all commits
4fa3eee
cacb020
5bd8774
7a5ef34
91d6857
865784f
e65ddd4
b1c9799
bde066e
d03b6f1
cba3483
578996e
13d6292
ca503ec
43fda79
28216f6
f3381e6
fd6bfc7
97c7432
cf0d483
2272782
6fae674
3e08bf8
aa92b80
82519ed
95b0b44
37dcc34
6566fb0
3752b4e
63d855c
d54af74
43f6446
0e18df1
3a36481
04dfd69
4d4484b
afca919
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
VyePolicy = Struct.new(:user, :user_info) do | ||
def access? | ||
return true if user.present? | ||
|
||
false | ||
end | ||
|
||
alias_method :claimant_lookup?, :access? | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
require 'central_mail/configuration' | ||
require 'debt_management_center/debts_configuration' | ||
require 'decision_review/configuration' | ||
require 'dgib/configuration' | ||
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. 'vye/dgib/configuration' |
||
require 'evss/claims_service' | ||
require 'evss/common_service' | ||
require 'evss/dependents/configuration' | ||
|
@@ -77,6 +78,7 @@ | |
SearchTypeahead::Configuration.instance.breakers_service, | ||
SearchClickTracking::Configuration.instance.breakers_service, | ||
VAOS::Configuration.instance.breakers_service, | ||
Vye::DGIB::Configuration.instance.breakers_service, | ||
IAMSSOeOAuth::Configuration.instance.breakers_service, | ||
CovidVaccine::V0::VetextConfiguration.instance.breakers_service, | ||
VEText::Configuration.instance.breakers_service, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'dgib/service' | ||
|
||
module Vye | ||
module Vye::V1 | ||
class Vye::V1::DgibVerificationsController < Vye::V1::ApplicationController | ||
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.
|
||
before_action { authorize :vye, :access? } | ||
|
||
def verification_record | ||
response = service.get_verification_record(params[:claimant_id]) | ||
serializer = Vye::ClaimantVerificationSerializer | ||
process_response(response, serializer) | ||
end | ||
|
||
def verify_claimant | ||
response = service.verify_claimant( | ||
params[:claimant_id], | ||
params[:verified_period_begin_date], | ||
params[:verified_period_end_date], | ||
params[:verified_through_date], | ||
params[:verification_method], | ||
params.dig(:app_communication, :response_type) | ||
) | ||
|
||
serializer = Vye::VerifyClaimantSerializer | ||
process_response(response, serializer) | ||
end | ||
|
||
# the serializer for this endpoint is the same as for verify_claimant | ||
def claimant_status | ||
response = service.get_claimant_status(params[:claimant_id]) | ||
serializer = Vye::VerifyClaimantSerializer | ||
process_response(response, serializer) | ||
end | ||
|
||
def claimant_lookup | ||
response = service.claimant_lookup(current_user.ssn) | ||
serializer = Vye::ClaimantLookupSerializer | ||
process_response(response, serializer) | ||
end | ||
|
||
private | ||
|
||
# Vye Services related stuff | ||
def service | ||
Vye::DGIB::Service.new(@current_user) | ||
end | ||
|
||
def process_response(response, serializer) | ||
Rails.logger.debug { "Processing response with status: #{response&.status}" } | ||
case response.status | ||
when 200 | ||
Rails.logger.debug 'Rendering JSON response' | ||
render json: serializer.new(response).to_json | ||
when 204 | ||
Rails.logger.debug 'Sending no content' | ||
head :no_content | ||
when 403 | ||
Rails.logger.debug 'Sending forbidden' | ||
head :forbidden | ||
when 404 | ||
Rails.logger.debug 'Sending not found' | ||
head :not_found | ||
when 422 | ||
Rails.logger.debug 'Sending unprocessable entity' | ||
head :unprocessable_entity | ||
when nil | ||
Rails.logger.debug 'No response from server' | ||
else | ||
Rails.logger.debug 'Sending internal server error' | ||
head :internal_server_error | ||
end | ||
end | ||
# End Vye Services | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vye | ||
class VyeSerializer | ||
attr_reader :resource | ||
|
||
def initialize(resource) | ||
@resource = resource | ||
end | ||
|
||
def to_json(*) | ||
Oj.dump(serializable_hash, mode: :compat, time_format: :ruby) | ||
end | ||
|
||
def status | ||
@resource&.status | ||
end | ||
end | ||
|
||
class ClaimantLookupSerializer < VyeSerializer | ||
def serializable_hash | ||
{ | ||
claimant_id: @resource&.claimant_id | ||
} | ||
end | ||
end | ||
|
||
class ClaimantVerificationSerializer < VyeSerializer | ||
def serializable_hash | ||
{ | ||
claimant_id: @resource&.claimant_id, | ||
delimiting_date: @resource&.delimiting_date, | ||
enrollment_verifications: @resource&.enrollment_verifications, | ||
verified_details: @resource&.verified_details, | ||
payment_on_hold: @resource&.payment_on_hold | ||
} | ||
end | ||
end | ||
|
||
class VerifyClaimantSerializer < VyeSerializer | ||
def serializable_hash | ||
{ | ||
claimant_id: @resource&.claimant_id, | ||
delimiting_date: @resource&.delimiting_date, | ||
verified_details: @resource&.verified_details, | ||
payment_on_hold: @resource&.payment_on_hold | ||
} | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
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. What does this file do? 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. This file was intended to resolve namespace problems. Now it is no longer needed as the namespace issues were fixed. |
||
|
||
# Zeitwerk was giving me fits until I added this. | ||
require Rails.root.join('modules', 'vye', 'lib', 'dgib', 'service') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vye | ||
module DGIB | ||
class AuthenticationTokenService | ||
ALGORITHM_TYPE = 'RS256' | ||
E = 'AQAB' | ||
TYP = 'JWT' | ||
KID = 'vye' | ||
USE = 'sig' | ||
SIGNING_KEY = Settings.dgi.vye.jwt.private_key_path | ||
RSA_PRIVATE = OpenSSL::PKey::RSA.new(File.read(SIGNING_KEY)) if File.exist?(SIGNING_KEY) | ||
|
||
def self.call | ||
payload = { | ||
exp: Time.now.to_i + (5 * 60), # JWT expiration time (5 minutes) | ||
nbf: Time.now.to_i, | ||
realm_access: { | ||
roles: ['VYE'] | ||
} | ||
} | ||
|
||
header_fields = { kid: KID, typ: TYP } | ||
|
||
JWT.encode payload, RSA_PRIVATE, ALGORITHM_TYPE, header_fields | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vye | ||
module DGIB | ||
class Configuration < Common::Client::Configuration::REST | ||
def connection | ||
@conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday| | ||
faraday.use :breakers | ||
faraday.ssl[:ca_file] = Settings.dgi.vye.public_ica11_rca2_key_path | ||
faraday.request :json | ||
faraday.use Faraday::Response::RaiseError | ||
faraday.response :betamocks if mock_enabled? | ||
faraday.response :snakecase, symbolize: false | ||
faraday.response :json, content_type: /\bjson/ # ensures only json content types parsed | ||
faraday.adapter Faraday.default_adapter | ||
end | ||
end | ||
|
||
def base_path | ||
Settings.dgi.vye.vets.url.to_s | ||
end | ||
|
||
def service_name | ||
'DGI' | ||
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. 'VYE/DGIB' There is already a DGI service |
||
end | ||
|
||
def mock_enabled? | ||
Settings.dgi.vye.vets.mock || false | ||
end | ||
end | ||
end | ||
end |
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.
Please undo this change