Skip to content
Merged
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
7 changes: 5 additions & 2 deletions app/services/irs_attempts_api/attempt_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def to_jwe
zip: 'DEF',
alg: 'RSA-OAEP',
enc: 'A256GCM',
kid: JWT::JWK.new(event_data_encryption_key).kid,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will probably allow us to remove the irs_attempt_api_public_key_id parameter later: https://github.com/18F/identity-idp/blob/main/config/application.yml.default#L347

Though that's a breaking schema change so we should hold off.

)
end

Expand Down Expand Up @@ -83,8 +84,10 @@ def event_data_encryption_key_id
end

def event_data_encryption_key
decoded_key_der = Base64.strict_decode64(IdentityConfig.store.irs_attempt_api_public_key)
OpenSSL::PKey::RSA.new(decoded_key_der)
@event_data_encryption_key ||= begin
decoded_key_der = Base64.strict_decode64(IdentityConfig.store.irs_attempt_api_public_key)
OpenSSL::PKey::RSA.new(decoded_key_der)
end
end
end
end
1 change: 1 addition & 0 deletions spec/services/irs_attempts_api/attempt_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
headers = JSON.parse(header_str)

expect(headers['alg']).to eq('RSA-OAEP')
expect(headers['kid']).to eq(JWT::JWK.new(irs_attempt_api_public_key).kid)

decrypted_jwe_payload = JWE.decrypt(jwe, irs_attempt_api_private_key)

Expand Down