omniauth-swedbank 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +24 -0
- data/README.md +49 -13
- data/docs/migration_008_to_009.md +89 -0
- data/lib/omniauth/strategies/swedbank.rb +168 -33
- data/lib/omniauth/swedbank/version.rb +1 -1
- data/omniauth-swedbank.gemspec +11 -9
- data/spec/certs/response.v009.public.pem +17 -0
- data/spec/omniauth/strategies/swedbank_spec.rb +393 -158
- metadata +49 -22
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 528ab8c0fad20b14c0e37c6c5ed9a027e801aebd8c365d88d3278a450f3f008b
|
|
4
|
+
data.tar.gz: afd969593c671e47716fe4ab9a8aec56f2d4af37ba2422e6f8c898830d6bd7fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4cd649797d99a39ae36c9874866a37c0622091232059723196eecfb39be7b1002e38fcde0d762f053e5031df280118a4ecc914bd10c45bb3e7fec75d87737f2
|
|
7
|
+
data.tar.gz: a27486b76f6f6dcd109d86efa93756df72694a146c0fa962821a6cdb4a160fcef89897839a2b12c97b66e5cbdf2f12e34600ee792e209430241d6614a1e220f8
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
ruby-version: ["3.1", "3.2", "3.3", "3.4", "4.0"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
22
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: bundle exec rspec
|
data/README.md
CHANGED
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Omniauth strategy for using Swedbank as an authentication service provider.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://travis-ci.org/mak-it/omniauth-swedbank)
|
|
7
|
-
|
|
8
|
-
Supported Ruby versions: 2.2+
|
|
5
|
+
Supported Ruby versions: 2.7+
|
|
9
6
|
|
|
10
7
|
## Related projects
|
|
11
8
|
|
|
12
|
-
- [omniauth-citadele](https://github.com/
|
|
13
|
-
- [omniauth-dnb](https://github.com/
|
|
14
|
-
- [omniauth-nordea](https://github.com/
|
|
15
|
-
- [omniauth-seb-elink](https://github.com/
|
|
9
|
+
- [omniauth-citadele](https://github.com/mitigate-dev/omniauth-citadele) - strategy for authenticating with Citadele
|
|
10
|
+
- [omniauth-dnb](https://github.com/mitigate-dev/omniauth-dnb) - strategy for authenticating with DNB
|
|
11
|
+
- [omniauth-nordea](https://github.com/mitigate-dev/omniauth-nordea) - strategy for authenticating with Nordea
|
|
12
|
+
- [omniauth-seb-elink](https://github.com/mitigate-dev/omniauth-seb-elink) - strategy for authenticating with SEB
|
|
16
13
|
|
|
17
14
|
## Installation
|
|
18
15
|
|
|
19
|
-
Add
|
|
16
|
+
Add these lines to your application's Gemfile (omniauth-rails_csrf_protection is required if using Rails):
|
|
20
17
|
|
|
18
|
+
gem 'omniauth-rails_csrf_protection'
|
|
21
19
|
gem 'omniauth-swedbank'
|
|
22
20
|
|
|
23
21
|
And then execute:
|
|
@@ -26,7 +24,11 @@ And then execute:
|
|
|
26
24
|
|
|
27
25
|
Or install it yourself as:
|
|
28
26
|
|
|
29
|
-
$ gem install omniauth-swedbank
|
|
27
|
+
$ gem install omniauth-rails_csrf_protection omniauth-swedbank
|
|
28
|
+
|
|
29
|
+
## v009 Migration
|
|
30
|
+
|
|
31
|
+
**Swedbank will shut down banklink protocol v008 on 2026-06-02.** See [Migration Guide](docs/migration_008_to_009.md) for details.
|
|
30
32
|
|
|
31
33
|
## Usage
|
|
32
34
|
|
|
@@ -39,13 +41,47 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
|
39
41
|
File.read("path/to/private.key"),
|
|
40
42
|
File.read("path/to/bank.crt"),
|
|
41
43
|
ENV['SWEDBANK_SND_ID'],
|
|
42
|
-
ENV['SWEDBANK_REC_ID']
|
|
44
|
+
ENV['SWEDBANK_REC_ID'],
|
|
45
|
+
version: '009'
|
|
43
46
|
end
|
|
44
47
|
```
|
|
45
48
|
|
|
49
|
+
The `version` option defaults to `'008'` for backward compatibility. Set it to `'009'` when you're ready to migrate (requires a new bank certificate from [banklink.swedbank.com](https://banklink.swedbank.com/public/resources/bank-certificates/009)).
|
|
50
|
+
|
|
46
51
|
## Auth Hash
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
### v009
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
{
|
|
57
|
+
provider: 'swedbank',
|
|
58
|
+
uid: '374042-80367',
|
|
59
|
+
info: {
|
|
60
|
+
full_name: 'ARNIS RAITUMS',
|
|
61
|
+
country: 'LV'
|
|
62
|
+
},
|
|
63
|
+
extra: {
|
|
64
|
+
raw_info: {
|
|
65
|
+
VK_SERVICE: '3013',
|
|
66
|
+
VK_VERSION: '009',
|
|
67
|
+
VK_DATETIME: '2026-04-29T12:00:00+0300',
|
|
68
|
+
VK_SND_ID: 'SWEDBANK_LV',
|
|
69
|
+
VK_REC_ID: 'MPLMT',
|
|
70
|
+
VK_NONCE: '20170425114529204413',
|
|
71
|
+
VK_USER_NAME: 'ARNIS RAITUMS',
|
|
72
|
+
VK_USER_ID: '374042-80367',
|
|
73
|
+
VK_COUNTRY: 'LV',
|
|
74
|
+
VK_OTHER: '',
|
|
75
|
+
VK_TOKEN: '7',
|
|
76
|
+
VK_RID: '',
|
|
77
|
+
VK_MAC: 'qrEMRf6YV...',
|
|
78
|
+
VK_ENCODING: 'UTF-8'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### v008 (deprecated)
|
|
49
85
|
|
|
50
86
|
```ruby
|
|
51
87
|
{
|
|
@@ -63,7 +99,7 @@ Here's an example Auth Hash available in `request.env['omniauth.auth']`:
|
|
|
63
99
|
VK_NONCE: '20170425114529204413',
|
|
64
100
|
VK_INFO: 'ISIK:090482-12549;NIMI:DACE ĀBOLA',
|
|
65
101
|
VK_MAC: 'qrEMRf6YV...',
|
|
66
|
-
VK_ENCODING: 'UTF-8
|
|
102
|
+
VK_ENCODING: 'UTF-8'
|
|
67
103
|
}
|
|
68
104
|
}
|
|
69
105
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Migration Guide: v008 to v009
|
|
2
|
+
|
|
3
|
+
## Deadline
|
|
4
|
+
|
|
5
|
+
Swedbank will shut down banklink protocol v008 on **2026-06-02**. After this date, all v008 authentication requests will be rejected by the bank.
|
|
6
|
+
|
|
7
|
+
## What Changed in v009
|
|
8
|
+
|
|
9
|
+
| Aspect | v008 | v009 |
|
|
10
|
+
|--------|------|------|
|
|
11
|
+
| Signing algorithm | SHA-1 | SHA-512 |
|
|
12
|
+
| Request service code | 4002 | 4012 |
|
|
13
|
+
| Response service code | 3003 | 3013 |
|
|
14
|
+
| VK_SND_ID in response | HP | SWEDBANK_LV |
|
|
15
|
+
| Bank certificate | Country-specific (LV) | Unified Baltic |
|
|
16
|
+
| Min. key strength | 1024 bits | 2048 bits (recommended 4096) |
|
|
17
|
+
| Response user data | VK_INFO (combined string) | VK_USER_NAME, VK_USER_ID, VK_COUNTRY, VK_OTHER, VK_TOKEN |
|
|
18
|
+
| New request fields | - | VK_DATETIME, VK_RID |
|
|
19
|
+
|
|
20
|
+
## Migration Steps
|
|
21
|
+
|
|
22
|
+
### 1. Update the gem
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bundle update omniauth-swedbank
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With the default configuration (`version: '008'`), everything continues to work as before. You will see a deprecation warning in logs.
|
|
29
|
+
|
|
30
|
+
### 2. Download the new bank certificate
|
|
31
|
+
|
|
32
|
+
The v009 protocol uses a new unified Baltic certificate. Download it from:
|
|
33
|
+
|
|
34
|
+
https://banklink.swedbank.com/public/resources/bank-certificates/009
|
|
35
|
+
|
|
36
|
+
Replace your existing Swedbank public certificate file with the new one.
|
|
37
|
+
|
|
38
|
+
### 3. Check your private key
|
|
39
|
+
|
|
40
|
+
Your RSA private key must be at least **2048 bits** (recommended: **4096 bits**). Keys must be regenerated every **24 months**. Check your key size with:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
openssl rsa -in your_private_key.pem -text -noout | head -1
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If it shows less than 2048 bits or is older than 2 years, generate a new keypair. See [Keypair Change Instruction (PDF)](https://swedbank.lv/static/pdf/business/d2d/collection/keypair_change_instruction_LV.pdf) for detailed steps. Two options:
|
|
47
|
+
|
|
48
|
+
- **Option A:** Use Swedbank's built-in keypair generator via the [support page](https://www.swedbank.lv/business/cash/banklink/integrate) (recommended). Log in, go to "My agreements", click "Update key" -> "Generate new key". Download and save the private key immediately — the bank does not store it.
|
|
49
|
+
- **Option B:** Generate your own keypair and upload the public key via self-service or email it to cashmanagement@swedbank.lv.
|
|
50
|
+
|
|
51
|
+
Note: When replacing keys, you can choose a transition period (up to 7 days) during which both old and new keys are valid.
|
|
52
|
+
|
|
53
|
+
### 4. Update your provider configuration
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# Before (v008 - default)
|
|
57
|
+
provider :swedbank,
|
|
58
|
+
File.read("path/to/private.key"),
|
|
59
|
+
File.read("path/to/old_bank.crt"),
|
|
60
|
+
ENV['SWEDBANK_SND_ID'],
|
|
61
|
+
ENV['SWEDBANK_REC_ID']
|
|
62
|
+
|
|
63
|
+
# After (v009)
|
|
64
|
+
provider :swedbank,
|
|
65
|
+
File.read("path/to/private.key"),
|
|
66
|
+
File.read("path/to/new_baltic_bank.crt"),
|
|
67
|
+
ENV['SWEDBANK_SND_ID'],
|
|
68
|
+
ENV['SWEDBANK_REC_ID'],
|
|
69
|
+
version: '009'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 5. Update your callback handling (if applicable)
|
|
73
|
+
|
|
74
|
+
If your application reads user data from the auth hash, note these changes:
|
|
75
|
+
|
|
76
|
+
**v008:** User ID and name were parsed from the `VK_INFO` field (`ISIK:123456-12345;NIMI:John Doe`).
|
|
77
|
+
|
|
78
|
+
**v009:** User data comes in separate fields:
|
|
79
|
+
- `auth.uid` - reads from `VK_USER_ID` directly
|
|
80
|
+
- `auth.info.full_name` - reads from `VK_USER_NAME` directly
|
|
81
|
+
- `auth.info.country` - new field from `VK_COUNTRY` (e.g., `LV`)
|
|
82
|
+
- `auth.extra.raw_info` - contains all response parameters including `VK_TOKEN`, `VK_OTHER`, `VK_RID`
|
|
83
|
+
|
|
84
|
+
If you only use `auth.uid` and `auth.info.full_name`, no changes are needed in your application code.
|
|
85
|
+
|
|
86
|
+
## Reference
|
|
87
|
+
|
|
88
|
+
- [Swedbank comparison PDF](https://www.swedbank.lv/static/business/banklink/LV_Authentication_008_vs_009_instruction.pdf)
|
|
89
|
+
- [Bank certificates for v009](https://banklink.swedbank.com/public/resources/bank-certificates/009)
|
|
@@ -6,8 +6,18 @@ module OmniAuth
|
|
|
6
6
|
class Swedbank
|
|
7
7
|
include OmniAuth::Strategy
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
V008_AUTH_SERVICE = '4002'
|
|
10
|
+
V008_RESPONSE_SERVICE = '3003'
|
|
11
|
+
V009_AUTH_SERVICE = '4012'
|
|
12
|
+
V009_RESPONSE_SERVICE = '3013'
|
|
13
|
+
|
|
14
|
+
def self.render_nonce?
|
|
15
|
+
defined?(ActionDispatch::ContentSecurityPolicy::Request) != nil
|
|
16
|
+
end
|
|
17
|
+
if render_nonce?
|
|
18
|
+
include ActionDispatch::ContentSecurityPolicy::Request
|
|
19
|
+
delegate :get_header, :set_header, to: :request
|
|
20
|
+
end
|
|
11
21
|
|
|
12
22
|
args [:private_key, :public_key, :snd_id, :rec_id]
|
|
13
23
|
|
|
@@ -18,40 +28,96 @@ module OmniAuth
|
|
|
18
28
|
|
|
19
29
|
option :name, 'swedbank'
|
|
20
30
|
option :site, 'https://www.swedbank.lv/banklink'
|
|
31
|
+
option :version, '008'
|
|
32
|
+
|
|
33
|
+
SUPPORTED_VERSIONS = %w[008 009].freeze
|
|
34
|
+
|
|
35
|
+
def version_009?
|
|
36
|
+
options.version == '009'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def invalid_version?
|
|
40
|
+
!SUPPORTED_VERSIONS.include?(options.version)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def auth_service
|
|
44
|
+
version_009? ? V009_AUTH_SERVICE : V008_AUTH_SERVICE
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def response_service
|
|
48
|
+
version_009? ? V009_RESPONSE_SERVICE : V008_RESPONSE_SERVICE
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def digest
|
|
52
|
+
version_009? ? OpenSSL::Digest::SHA512.new : OpenSSL::Digest::SHA1.new
|
|
53
|
+
end
|
|
21
54
|
|
|
22
55
|
def stamp
|
|
23
56
|
return @stamp if @stamp
|
|
24
57
|
@stamp = Time.now.strftime('%Y%m%d%H%M%S') + SecureRandom.random_number(999999).to_s.rjust(6, '0')
|
|
25
58
|
end
|
|
26
59
|
|
|
60
|
+
def datetime
|
|
61
|
+
@datetime ||= Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def rid
|
|
65
|
+
''
|
|
66
|
+
end
|
|
67
|
+
|
|
27
68
|
def prepend_length(value)
|
|
28
69
|
# prepend length to string in 0xx format
|
|
29
70
|
[ value.to_s.length.to_s.rjust(3, '0'), value.dup.to_s.force_encoding('ascii')].join
|
|
30
71
|
end
|
|
31
72
|
|
|
32
73
|
def signature_input
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
74
|
+
fields = if version_009?
|
|
75
|
+
[
|
|
76
|
+
auth_service, # VK_SERVICE
|
|
77
|
+
options.version, # VK_VERSION
|
|
78
|
+
options.snd_id, # VK_SND_ID
|
|
79
|
+
options.rec_id, # VK_REC_ID
|
|
80
|
+
stamp, # VK_NONCE
|
|
81
|
+
callback_url, # VK_RETURN
|
|
82
|
+
datetime, # VK_DATETIME
|
|
83
|
+
rid # VK_RID
|
|
84
|
+
]
|
|
85
|
+
else
|
|
86
|
+
[
|
|
87
|
+
auth_service, # VK_SERVICE
|
|
88
|
+
options.version, # VK_VERSION
|
|
89
|
+
options.snd_id, # VK_SND_ID
|
|
90
|
+
options.rec_id, # VK_REC_ID
|
|
91
|
+
stamp, # VK_NONCE
|
|
92
|
+
callback_url # VK_RETURN
|
|
93
|
+
]
|
|
94
|
+
end
|
|
95
|
+
fields.map{|v| prepend_length(v)}.join
|
|
41
96
|
end
|
|
42
97
|
|
|
43
98
|
def signature(priv_key)
|
|
44
|
-
Base64.encode64(priv_key.sign(
|
|
99
|
+
Base64.encode64(priv_key.sign(digest, signature_input))
|
|
45
100
|
end
|
|
46
101
|
|
|
47
102
|
uid do
|
|
48
|
-
|
|
103
|
+
if version_009?
|
|
104
|
+
request.params['VK_USER_ID']
|
|
105
|
+
else
|
|
106
|
+
request.params['VK_INFO'].match(/ISIK:(\d{6}\-\d{5})/)[1]
|
|
107
|
+
end
|
|
49
108
|
end
|
|
50
109
|
|
|
51
110
|
info do
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
111
|
+
if version_009?
|
|
112
|
+
{
|
|
113
|
+
full_name: request.params['VK_USER_NAME'],
|
|
114
|
+
country: request.params['VK_COUNTRY']
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
{
|
|
118
|
+
full_name: request.params['VK_INFO'].match(/NIMI:(.+)/)[1]
|
|
119
|
+
}
|
|
120
|
+
end
|
|
55
121
|
end
|
|
56
122
|
|
|
57
123
|
extra do
|
|
@@ -59,17 +125,22 @@ module OmniAuth
|
|
|
59
125
|
end
|
|
60
126
|
|
|
61
127
|
def callback_phase
|
|
128
|
+
if invalid_version?
|
|
129
|
+
return fail!(:unsupported_version_err,
|
|
130
|
+
ArgumentError.new("Unsupported banklink version '#{options.version}'. Supported: #{SUPPORTED_VERSIONS.join(', ')}"))
|
|
131
|
+
end
|
|
132
|
+
|
|
62
133
|
begin
|
|
63
134
|
pub_key = OpenSSL::X509::Certificate.new(options.public_key).public_key
|
|
64
135
|
rescue => e
|
|
65
136
|
return fail!(:public_key_load_err, e)
|
|
66
137
|
end
|
|
67
138
|
|
|
68
|
-
if request.params['VK_SERVICE'] !=
|
|
139
|
+
if request.params['VK_SERVICE'] != response_service
|
|
69
140
|
return fail!(:unsupported_response_service_err)
|
|
70
141
|
end
|
|
71
142
|
|
|
72
|
-
if request.params['VK_VERSION'] !=
|
|
143
|
+
if request.params['VK_VERSION'] != options.version
|
|
73
144
|
return fail!(:unsupported_response_version_err)
|
|
74
145
|
end
|
|
75
146
|
|
|
@@ -77,18 +148,35 @@ module OmniAuth
|
|
|
77
148
|
return fail!(:unsupported_response_encoding_err)
|
|
78
149
|
end
|
|
79
150
|
|
|
80
|
-
sig_str =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
151
|
+
sig_str = if version_009?
|
|
152
|
+
[
|
|
153
|
+
request.params['VK_SERVICE'],
|
|
154
|
+
request.params['VK_VERSION'],
|
|
155
|
+
request.params['VK_DATETIME'],
|
|
156
|
+
request.params['VK_SND_ID'],
|
|
157
|
+
request.params['VK_REC_ID'],
|
|
158
|
+
request.params['VK_NONCE'],
|
|
159
|
+
request.params['VK_USER_NAME'],
|
|
160
|
+
request.params['VK_USER_ID'],
|
|
161
|
+
request.params['VK_COUNTRY'],
|
|
162
|
+
request.params['VK_OTHER'],
|
|
163
|
+
request.params['VK_TOKEN'],
|
|
164
|
+
request.params['VK_RID']
|
|
165
|
+
].map{|v| prepend_length(v)}.join
|
|
166
|
+
else
|
|
167
|
+
[
|
|
168
|
+
request.params['VK_SERVICE'],
|
|
169
|
+
request.params['VK_VERSION'],
|
|
170
|
+
request.params['VK_SND_ID'],
|
|
171
|
+
request.params['VK_REC_ID'],
|
|
172
|
+
request.params['VK_NONCE'],
|
|
173
|
+
request.params['VK_INFO']
|
|
174
|
+
].map{|v| prepend_length(v)}.join
|
|
175
|
+
end
|
|
88
176
|
|
|
89
177
|
raw_signature = Base64.decode64(request.params['VK_MAC'])
|
|
90
178
|
|
|
91
|
-
if !pub_key.verify(
|
|
179
|
+
if !pub_key.verify(digest, raw_signature, sig_str)
|
|
92
180
|
return fail!(:invalid_response_signature_err)
|
|
93
181
|
end
|
|
94
182
|
|
|
@@ -96,34 +184,81 @@ module OmniAuth
|
|
|
96
184
|
end
|
|
97
185
|
|
|
98
186
|
def request_phase
|
|
187
|
+
if invalid_version?
|
|
188
|
+
return fail!(:unsupported_version_err,
|
|
189
|
+
ArgumentError.new("Unsupported banklink version '#{options.version}'. Supported: #{SUPPORTED_VERSIONS.join(', ')}"))
|
|
190
|
+
end
|
|
191
|
+
|
|
99
192
|
begin
|
|
100
193
|
priv_key = OpenSSL::PKey::RSA.new(options.private_key)
|
|
101
194
|
rescue => e
|
|
102
195
|
return fail!(:private_key_load_err, e)
|
|
103
196
|
end
|
|
104
197
|
|
|
198
|
+
unless version_009?
|
|
199
|
+
warn "[DEPRECATION] omniauth-swedbank: Swedbank banklink v008 will be shut down on 2026-06-02. " \
|
|
200
|
+
"Please migrate to v009 by setting `version: '009'` in your provider config. " \
|
|
201
|
+
"See https://www.swedbank.lv/static/business/banklink/LV_Authentication_008_vs_009_instruction.pdf"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
set_locale_from_query_param
|
|
205
|
+
|
|
105
206
|
form = OmniAuth::Form.new(:title => I18n.t('omniauth.swedbank.please_wait'), :url => options.site)
|
|
106
207
|
|
|
107
|
-
{
|
|
108
|
-
'VK_SERVICE' =>
|
|
109
|
-
'VK_VERSION' =>
|
|
208
|
+
params = {
|
|
209
|
+
'VK_SERVICE' => auth_service,
|
|
210
|
+
'VK_VERSION' => options.version,
|
|
110
211
|
'VK_SND_ID' => options.snd_id,
|
|
111
212
|
'VK_REC_ID' => options.rec_id,
|
|
112
213
|
'VK_NONCE' => stamp,
|
|
113
214
|
'VK_RETURN' => callback_url,
|
|
114
215
|
'VK_MAC' => signature(priv_key),
|
|
115
|
-
'VK_LANG' =>
|
|
216
|
+
'VK_LANG' => resolve_bank_ui_language,
|
|
116
217
|
'VK_ENCODING' => 'UTF-8'
|
|
117
|
-
}
|
|
118
|
-
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if version_009?
|
|
221
|
+
params['VK_DATETIME'] = datetime
|
|
222
|
+
params['VK_RID'] = rid
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
params.each do |name, val|
|
|
226
|
+
form.html "<input type=\"hidden\" name=\"#{name}\" value=\"#{escape(val)}\" />"
|
|
119
227
|
end
|
|
120
228
|
|
|
121
229
|
form.button I18n.t('omniauth.swedbank.click_here_if_not_redirected')
|
|
122
230
|
|
|
231
|
+
nonce_attribute = nil
|
|
232
|
+
if self.class.render_nonce?
|
|
233
|
+
nonce_attribute = " nonce='#{escape(content_security_policy_nonce)}'"
|
|
234
|
+
end
|
|
123
235
|
form.instance_variable_set('@html',
|
|
124
|
-
form.to_html.gsub('</form>',
|
|
236
|
+
form.to_html.gsub('</form>', "</form><script type=\"text/javascript\"#{nonce_attribute}>document.forms[0].submit();</script>"))
|
|
125
237
|
form.to_response
|
|
126
238
|
end
|
|
239
|
+
|
|
240
|
+
private
|
|
241
|
+
|
|
242
|
+
def set_locale_from_query_param
|
|
243
|
+
locale = request.params['locale']
|
|
244
|
+
if (locale != nil && locale.strip != '' && I18n.locale_available?(locale))
|
|
245
|
+
I18n.locale = locale
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def resolve_bank_ui_language
|
|
250
|
+
case I18n.locale
|
|
251
|
+
when :ru then 'RUS'
|
|
252
|
+
when :en then 'ENG'
|
|
253
|
+
when :et then 'EST'
|
|
254
|
+
when :lt then 'LIT'
|
|
255
|
+
else 'LAT'
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def escape(html_attribute_value)
|
|
260
|
+
CGI.escapeHTML(html_attribute_value) unless html_attribute_value.nil?
|
|
261
|
+
end
|
|
127
262
|
end
|
|
128
263
|
end
|
|
129
264
|
end
|
data/omniauth-swedbank.gemspec
CHANGED
|
@@ -6,11 +6,11 @@ require 'omniauth/swedbank/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'omniauth-swedbank'
|
|
8
8
|
spec.version = Omniauth::Swedbank::VERSION
|
|
9
|
-
spec.authors = ['
|
|
10
|
-
spec.email = ['admin@
|
|
9
|
+
spec.authors = ['Mitigate', 'Jānis Kiršteins', 'Kristaps Ērglis']
|
|
10
|
+
spec.email = ['admin@mitigate.dev', 'janis@montadigital.com', 'kristaps.erglis@gmail.com' ]
|
|
11
11
|
spec.description = %q{OmniAuth strategy for Swedbank Banklink}
|
|
12
12
|
spec.summary = %q{OmniAuth strategy for Swedbank Banklink}
|
|
13
|
-
spec.homepage = 'https://github.com/
|
|
13
|
+
spec.homepage = 'https://github.com/mitigate-dev/omniauth-swedbank'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
|
@@ -18,13 +18,15 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
spec.required_ruby_version = '>=
|
|
21
|
+
spec.required_ruby_version = '>= 3.1'
|
|
22
22
|
|
|
23
|
-
spec.add_runtime_dependency 'omniauth', '~> 1
|
|
24
|
-
spec.add_runtime_dependency
|
|
23
|
+
spec.add_runtime_dependency 'omniauth', '~> 2.1'
|
|
24
|
+
spec.add_runtime_dependency 'i18n'
|
|
25
25
|
|
|
26
|
+
spec.add_development_dependency 'rack'
|
|
26
27
|
spec.add_development_dependency 'rack-test'
|
|
27
|
-
spec.add_development_dependency 'rspec'
|
|
28
|
-
spec.add_development_dependency
|
|
29
|
-
spec.add_development_dependency
|
|
28
|
+
spec.add_development_dependency 'rspec'
|
|
29
|
+
spec.add_development_dependency 'bundler'
|
|
30
|
+
spec.add_development_dependency 'rake'
|
|
31
|
+
spec.add_development_dependency 'rack-session'
|
|
30
32
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIICoTCCAYmgAwIBAgIBATANBgkqhkiG9w0BAQ0FADAUMRIwEAYDVQQDDAlUZXN0
|
|
3
|
+
IFYwMDkwHhcNMjYwNDI5MDkyNjQ5WhcNMjcwNDI5MDkyNjQ5WjAUMRIwEAYDVQQD
|
|
4
|
+
DAlUZXN0IFYwMDkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtZLYp
|
|
5
|
+
KJNe16Fp2S/EVyyz0aFdPhBwgn+707JW/a8EM1m0rryNUbwZpQqZ2wzmPy6r/D13
|
|
6
|
+
UssJpGVg74+LQ8GZI+mgiL+U7nY95111XhOQ/B258i40HAwf3WFVqDKmigYxXU+O
|
|
7
|
+
0hbuUwXmT7qP3sRNgNLChn6BFDV6c1f/TYkiSZrSj45HQsqDekCIZdy6CvzV8m5I
|
|
8
|
+
JV3TJWshoEj4HPJI7YEkgjc3nzwUsKiLi9k6FsLSiveFBaky+mhYBlJUtET7KEwu
|
|
9
|
+
raHw7LkCn1FoCSodgxeHF9IFCCyKTI7VKETB4w0TYLKCbMOjtON0ifCx+H/w8LwP
|
|
10
|
+
YrhXTF6rjcdL3A9jAgMBAAEwDQYJKoZIhvcNAQENBQADggEBAErV4sBKLwmUvjOT
|
|
11
|
+
S8Kjw+BwTf0NU/yOpQS1kCSTD5gn9OOqDirOQe7Yj1dyGWMDmfGy4Jw7xcMSRTTq
|
|
12
|
+
TCKS7poTkFa8mXRPm+kFqw1Hy3U6/MsswZCBxiIkGEltKytXe+AdLVY2uM46/j6W
|
|
13
|
+
D6Rt0vgcBcj//h2et4f8GDMs4s1ndKp8o0rnggSQCcgC2yLMNL8AdSxwHj7eGDiv
|
|
14
|
+
cCWspZCXq7SGOoMC3jhhNOYt9WjH+/Aj/FXDRu2iguaG4I4qBGJSmY2i4WQT/XJv
|
|
15
|
+
sXPCrHoN0oGrmzX/V5/20AEOhS6oBLCIMfBeR4iRAicUW9mUnVj+PqigZkXGSArB
|
|
16
|
+
tkkI44U=
|
|
17
|
+
-----END CERTIFICATE-----
|