-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed swedbank notification security issue
- Loading branch information
Showing
13 changed files
with
149 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
module SacPS | ||
module Auth | ||
module Banklink | ||
|
||
def generate_signature(service_msg_number, sigparams, required_service_params) | ||
privkey = self.class.parent.get_private_key | ||
privkey.sign(OpenSSL::Digest::SHA1.new, generate_data_string(service_msg_number, sigparams, required_service_params)) | ||
private_key = self.class.parent.get_private_key | ||
private_key.sign(OpenSSL::Digest::SHA1.new, generate_data_string(service_msg_number, sigparams, required_service_params)) | ||
end | ||
|
||
def generate_mac(service_msg_number, sigparams, required_service_params) | ||
Base64.encode64(generate_signature(service_msg_number, sigparams, required_service_params)).gsub(/\n/,'') | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICsDCCAhmgAwIBAgIJAJ3net+nsGZhMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV | ||
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX | ||
aWRnaXRzIFB0eSBMdGQwHhcNMTYwNTEzMDY0MTMyWhcNMjYwNTExMDY0MTMyWjBF | ||
MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 | ||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB | ||
gQC6ws539UnzhBlgml3XyoAJWPox+BbbPVGhsFlCfitqRJbsFAd0EEQVODaQaHGI | ||
JgfHUdeG/1n/KmF0qPN2Zio7ULaKPb99UKVjHdEHyD1/r74wh79KYzr0A4wR2JjA | ||
o6cD3cfXpyM8/YQ6LEhnrLpqoGqZE9y1Bn8cpUjMCt1cuQIDAQABo4GnMIGkMB0G | ||
A1UdDgQWBBSL2IbcJCA4fz04lPEH5adjutYRFTB1BgNVHSMEbjBsgBSL2IbcJCA4 | ||
fz04lPEH5adjutYRFaFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt | ||
U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAJ3net+n | ||
sGZhMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAax9F0uP2/1nGNS57 | ||
QVZ7dZbgworZ4C/8HM6wqeVUaianMOdms5YWVRgApJOOCvrZQu+EL5XVFkmuh05e | ||
zTltaUq7oeu89O/+V5YLhuaNfS24Ku7xde8niheSuqPxGSPbEz8FAA4IFlL4cyy2 | ||
hs71mAJJNeAMoYzUQbwcC8Pmm9U= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIICXQIBAAKBgQC6ws539UnzhBlgml3XyoAJWPox+BbbPVGhsFlCfitqRJbsFAd0 | ||
EEQVODaQaHGIJgfHUdeG/1n/KmF0qPN2Zio7ULaKPb99UKVjHdEHyD1/r74wh79K | ||
Yzr0A4wR2JjAo6cD3cfXpyM8/YQ6LEhnrLpqoGqZE9y1Bn8cpUjMCt1cuQIDAQAB | ||
AoGAGBvFo16aqUDINdw3eP++/3Xo9kJcUPjdbM3i995ppFIuWVNMkwL2hva2tHWH | ||
Elg2cNhzxg14hKPn6LNWmlYd5UlwYtHnsDsMSz/VPkPQQL7Eh50i6X91+K0+KuPv | ||
twEplE+RDI8ceqwJpvMU9ikmLE3CBTARrtzE4x4flIW6Q3ECQQD2MdbiwoitcyhQ | ||
RWOjlXMZJXY3X/0WJUohZpDZN9yPECoFR5kbY/WfS22kPctmqsFKISc7YbFRlwj+ | ||
Npf+Ed9PAkEAwjL9mtJI63D6481Nckm98RiYX04I13MaO4JWcuSdXc0ISlvOsyzE | ||
JRTCdn5JihNeqEglKfmIp9d/aIhhKIzBdwJAENsSsk3NW8rBnNVTYBTQX41gDaSF | ||
yGlfLPA/xI99i1H4/omLYwOyAmkApbkRXwMb3r5sWDV1FXf4xqboOx3wIwJBAK/4 | ||
+KlkR8NhG1d1X+piPAXOnbQuyABDQtAN6TwvQRIQiqSm0IS32f0n9JbfFNBTgQDI | ||
bzS780L0GXWlrzTJZz0CQQDLVVbVo1Jt2q53du5kbmzeWAwHjfs19vshhIB1vR+A | ||
q87qQ7T/XFW27gFfBItQpch4yDKZDPRupcYVEMgMSKeB | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Mock | ||
module Auth | ||
module Swedbank | ||
include SacPS::Auth::Common | ||
include SacPS::Auth::Banklink | ||
|
||
mattr_accessor :public_key | ||
mattr_accessor :private_key | ||
mattr_accessor :required_service_params | ||
|
||
def self.get_public_key | ||
cert = self.public_key | ||
OpenSSL::X509::Certificate.new(cert.gsub(/ /, '')).public_key | ||
end | ||
|
||
def self.get_private_key | ||
private_key = self.private_key | ||
OpenSSL::PKey::RSA.new(private_key.gsub(/ /, '')) | ||
end | ||
|
||
self.required_service_params = { | ||
3003 => [ | ||
'VK_SERVICE', | ||
'VK_VERSION', | ||
'VK_SND_ID', | ||
'VK_REC_ID', | ||
'VK_NONCE', | ||
'VK_INFO' | ||
] | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Mock | ||
module Auth | ||
module Swedbank | ||
class NotificationGenerator | ||
include SacPS::Auth::Common | ||
include SacPS::Auth::Banklink | ||
|
||
attr_reader :fields | ||
# VK_SERVICE | ||
# VK_VERSION | ||
# VK_SND_ID | ||
# VK_REC_ID | ||
# VK_NONCE | ||
# VK_INFO | ||
# VK_ENCODING | ||
# VK_MAC | ||
def initialize options={} | ||
|
||
@fields = {} | ||
|
||
@fields['VK_SERVICE'] = '3003' | ||
@fields['VK_VERSION'] = '008' | ||
@fields['VK_SND_ID'] = 'HP' | ||
@fields['VK_REC_ID'] = 'REFEREND' | ||
@fields['VK_NONCE'] = generate_random_string 50 | ||
@fields['VK_INFO'] = "ISIK:150174-12312;NIMI:KRISTIĀNS BĒRZIŅŠ" | ||
@fields['VK_ENCODING'] = "UTF-8" | ||
@fields['VK_MAC'] = generate_mac(@fields['VK_SERVICE'], @fields, SacPS::Auth::Swedbank.required_service_params) | ||
end | ||
|
||
def generate_raw_response | ||
values = @fields.collect{|key, value| "#{key}=#{value}"}.join('&') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'auth/swedbank' | ||
require 'auth/swedbank/notification_generator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters