Skip to content

Commit 125e888

Browse files
committed
Merge remote-tracking branch 'origin/main' into GYR1-807-language-routing
2 parents a4669a1 + fa13a9c commit 125e888

File tree

22 files changed

+317
-34
lines changed

22 files changed

+317
-34
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ commands:
5757
- run:
5858
name: install bundler & ruby dependencies
5959
command: |
60-
gem install bundler:2.3.5 --no-document && \
61-
bundle install --jobs=4 --retry=3 --path vendor/bundle
60+
gem install bundler:2.5.18 --no-document
61+
bundle config set --local path 'vendor/bundle'
62+
bundle install --jobs=4 --retry=3
6263
- save_cache:
6364
key: bundle-{{ checksum "Gemfile.lock" }}
6465
paths: [/mnt/ramdisk/vendor/bundle]

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ group :development do
145145
gem 'stackprof'
146146
gem 'memory_profiler'
147147
gem "letter_opener"
148+
gem "faraday"
148149
end
149150

150151
group :test do

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ DEPENDENCIES
789789
dotenv
790790
easy_translate
791791
factory_bot_rails
792+
faraday
792793
fix-db-schema-conflicts
793794
flamegraph
794795
flipper
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module StateFile
2+
module FystSunsetRedirectConcern
3+
extend ActiveSupport::Concern
4+
5+
included do
6+
before_action :sunset_redirect_to_homepage
7+
end
8+
9+
private
10+
11+
def sunset_redirect_to_homepage
12+
if Flipper.enabled?(:fyst_sunset_pya_live)
13+
redirect_to root_path
14+
end
15+
end
16+
end
17+
end

app/controllers/hub/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def activate_all_role_param
9595

9696
def organization_form_params
9797
params.require(:hub_organization_form).permit(
98-
:name, :is_independent, :states, :coalition_id, :timezone, :accepts_itin_applicants, :capacity_limit, :allows_greeters, source_parameters_attributes: [:_destroy, :id, :code]
98+
:name, :is_independent, :states, :coalition_id, :timezone, :accepts_itin_applicants, :capacity_limit, :allows_greeters, :national_overflow_location, source_parameters_attributes: [:_destroy, :id, :code]
9999
)
100100
end
101101

app/controllers/state_file/landing_page_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module StateFile
22
class LandingPageController < ApplicationController
33
include StateFile::StateFileControllerConcern
4+
include StateFile::FystSunsetRedirectConcern
45
layout "state_file"
56

67
def edit

app/controllers/state_file/questions/questions_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module StateFile
22
module Questions
33
class QuestionsController < ::Questions::QuestionsController
4+
include StateFile::FystSunsetRedirectConcern
45
include StateFile::StateFileIntakeConcern
56
before_action :redirect_if_no_intake, :redirect_if_in_progress_intakes_ended, :redirect_if_df_data_required
67

app/forms/hub/organization_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class OrganizationForm < Form
44

55
attr_accessor :organization
66

7-
set_attributes_for :organization, :name, :coalition_id, :accepts_itin_applicants, :timezone, :capacity_limit, :allows_greeters
7+
set_attributes_for :organization, :name, :coalition_id, :accepts_itin_applicants, :timezone, :capacity_limit, :allows_greeters, :national_overflow_location
88
set_attributes_for :state_routing_targets, :states
99
set_attributes_for :organization_synthetic_attributes, :is_independent
1010

app/jobs/process_text_message_attachments_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class MissingAttachmentError < StandardError; end
22

33
class ProcessTextMessageAttachmentsJob < ApplicationJob
4-
retry_on MissingAttachmentError
4+
retry_on MissingAttachmentError, attempts: 10
55

66
def perform(incoming_text_message_id, client_id, params)
77
attachments = TwilioService.new.parse_attachments(params)

app/services/irs_api_service.rb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,42 @@ def self.import_federal_data(authorization_code, _state_code)
8484
return
8585
end
8686

87+
decrypted_response = decrypt_response(
88+
cert_finder.client_key,
89+
Base64.decode64(response.header['SESSION-KEY']),
90+
Base64.decode64(response.header['INITIALIZATION-VECTOR']),
91+
Base64.decode64(JSON.parse(response.body)['taxReturn']),
92+
Base64.decode64(response.header['AUTHENTICATION-TAG'])
93+
)
94+
95+
decrypted_json = JSON.parse(decrypted_response)
96+
decrypted_json['xml'] = Nokogiri::XML(decrypted_json['xml']).to_xml
97+
98+
decrypted_json
99+
end
100+
101+
def self.decrypt_response(private_key, encrypted_secret, initialization_vector, encrypted_data, authentication_tag = nil)
87102
decipher = OpenSSL::Cipher.new('aes-256-gcm')
88103
decipher.decrypt
89-
client_key = cert_finder.client_key
90-
encrypted_session_key = Base64.decode64(response.header['SESSION-KEY'])
91104

92105
label = ''
93106
md_oaep = OpenSSL::Digest::SHA256
94107
md_mgf1 = OpenSSL::Digest::SHA1
95108

96-
decipher.key = client_key.private_decrypt_oaep(encrypted_session_key, label, md_oaep, md_mgf1)
97-
decipher.iv = Base64.decode64(response.header['INITIALIZATION-VECTOR'])
98-
encrypted_tax_return_bytes = Base64.decode64(JSON.parse(response.body)['taxReturn'])
109+
decipher.key = private_key.private_decrypt_oaep(encrypted_secret, label, md_oaep, md_mgf1)
110+
decipher.iv = initialization_vector
99111

100112
if ENV['IRS_API_LOCALHOST']
101-
decipher.auth_tag = Base64.decode64(response.header['AUTHENTICATION-TAG'])
113+
decipher.auth_tag = authentication_tag
102114
else
103-
char_array = encrypted_tax_return_bytes.unpack("C*")
104-
encrypted_tax_return_bytes = char_array[0..-17].pack("C*")
115+
char_array = encrypted_data.unpack("C*")
116+
encrypted_data = char_array[0..-17].pack("C*")
105117
auth_tag = char_array.last(16).pack("C*")
106118

107119
decipher.auth_tag = auth_tag
108120
end
109-
plain = decipher.update(encrypted_tax_return_bytes) + decipher.final
110-
111-
decrypted_json = JSON.parse(plain)
112-
decrypted_json['xml'] = Nokogiri::XML(decrypted_json['xml']).to_xml
113121

114-
decrypted_json
122+
decipher.update(encrypted_data) + decipher.final
115123
end
116124

117125
private

0 commit comments

Comments
 (0)