bankid 1.0.1 → 3.1.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 +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +9 -78
- data/Rakefile +2 -13
- data/config/certs/client_certificate.key +33 -0
- data/config/certs/client_certificate.p12 +0 -0
- data/config/certs/client_certificate.pem +32 -0
- data/config/locales/en.yml +15 -0
- data/config/locales/sv.yml +15 -0
- data/lib/bankid/client.rb +76 -0
- data/lib/bankid/railtie.rb +13 -0
- data/lib/bankid/result.rb +75 -0
- data/lib/bankid/secret.rb +38 -0
- data/lib/bankid/version.rb +1 -1
- data/lib/bankid.rb +39 -96
- data/lib/tasks/bankid_tasks.rake +5 -0
- metadata +34 -24
- data/.rubocop.yml +0 -34
- data/CHANGELOG.md +0 -21
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -86
- data/LICENSE.txt +0 -21
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/config/certs/development_client_certificate.key +0 -33
- data/config/certs/development_client_certificate.p12 +0 -0
- data/config/certs/development_client_certificate.pem +0 -32
- data/lib/bankid/authentication.rb +0 -23
- data/lib/bankid/poll.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a863cfc790617c338984cc4cb33ea283dfb63cdb36f518607adf560f9bdae4ee
|
4
|
+
data.tar.gz: 8e5c5e43226d682372252724e910b5c3bed6c5ae11823f1046b27c83781e74d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3d064e3cb91da35373f8bf59460dafa2f9956ba277729e6df4b22f39de0ba672cc8d20eabae6b20812cbf91f30d429b5eba07af0560bfd69ea560ad48592ec
|
7
|
+
data.tar.gz: a37bf0af5b9843b36832e50ea461bea69a739f72f3cb8bcf91c5e0d3bfbfb746d05485385f49c1fe53625db7c5d3850ffb0fef087e6333a512db61c61b089048
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright Johan Halse
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,93 +1,24 @@
|
|
1
1
|
# Bankid
|
2
|
-
|
3
|
-
Bankid authentication for Ruby!
|
2
|
+
Bankid login for Rails!
|
4
3
|
|
5
4
|
## Installation
|
6
|
-
|
7
5
|
Add this line to your application's Gemfile:
|
8
6
|
|
9
7
|
```ruby
|
10
|
-
gem
|
8
|
+
gem "bankid"
|
11
9
|
```
|
12
10
|
|
13
11
|
And then execute:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install bankid
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
Bankid authentication is done in the following steps:
|
24
|
-
|
25
|
-
1. Generate an "authentication order" by hitting the `auth` endpoint
|
26
|
-
2. You get an authentication object containing, among other things, an `orderRef` and a `startSecret` back
|
27
|
-
3. Use the data contained in the authentication object to show the user a QR code
|
28
|
-
4. Poll the `collect` endpoint every now and then using the `orderRef` you got back in the second step
|
29
|
-
5. When user has scanned the QR code and logged in, the poll will return their data.
|
30
|
-
|
31
|
-
This is step 1:
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
client = Bankid::Auth.new
|
35
|
-
auth = client.generate_authentication(ip: request.remote_ip) # user's ip address
|
36
|
-
```
|
37
|
-
|
38
|
-
Keep the values from that `auth` object around, you'll need them in later steps, as you'll see. Note that you should never reveal the `qr_start_secret` to users!
|
39
|
-
|
40
|
-
Onward to step 3, showing a QR code:
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
@qr_code = client.generate_qr(
|
44
|
-
start_token: auth.qr_start_token,
|
45
|
-
start_secret: auth.qr_start_secret,
|
46
|
-
seconds: seconds_elapsed_since_auth_response_received
|
47
|
-
)
|
48
|
-
```
|
49
|
-
|
50
|
-
Bankid uses animated QR, which means the code is a SHA256 hex digest that includes elapsed seconds. You'll need some way to keep track of those as you refresh the QR code and poll for a response.
|
51
|
-
|
52
|
-
Final step:
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
response = client.poll(order_ref: auth.order_ref)
|
56
|
-
raise "logged in!" if response.status == "complete"
|
57
|
-
```
|
58
|
-
|
59
|
-
Keep polling until your response status changes to "complete", and the response object will be a struct containing the `completion_data` property you're ultimately looking for.
|
60
|
-
|
61
|
-
## Certificates
|
62
|
-
|
63
|
-
Your BankID provider will have given you a certificate. It might be in `.p12` format. If that's the case, you'll need to convert it to an OpenSSL X509 certificate - version 0.1.x of the BankID gem relied on PKCS12 which saw [big changes in OpenSSL v3](https://github.com/johanhalse/bankid/issues/3), so the implementation has been switched to X509 instead. The gem looks for a certificate and a key in these default locations:
|
64
|
-
|
12
|
+
```bash
|
13
|
+
$ bundle
|
65
14
|
```
|
66
|
-
./config/certs/#{environment}_client_certificate.pem
|
67
|
-
./config/certs/#{environment}_client_certificate.key
|
68
|
-
```
|
69
|
-
|
70
|
-
If you're upgrading from 0.1.x and want to convert an existing p12 key, it's pretty straightforward:
|
71
15
|
|
16
|
+
Or install it yourself as:
|
17
|
+
```bash
|
18
|
+
$ gem install bankid
|
72
19
|
```
|
73
|
-
|
74
|
-
|
75
|
-
# Export key
|
76
|
-
openssl pkcs12 -legacy -in my_certificate.p12 -clcerts -nocerts -out my_certificate.key
|
77
|
-
```
|
78
|
-
|
79
|
-
That should hopefully get things running again.
|
80
|
-
|
81
|
-
## Development
|
82
|
-
|
83
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
84
|
-
|
85
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
86
|
-
|
87
|
-
## Contributing
|
88
|
-
|
89
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bankid.
|
20
|
+
## Usage
|
21
|
+
See [the wiki](https://github.com/johanhalse/bankid/wiki) for how to get started. The gem has seen a major overhaul from version 2 to version 3 and works very differently now.
|
90
22
|
|
91
23
|
## License
|
92
|
-
|
93
24
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "bundler/
|
4
|
-
require "rake/testtask"
|
5
|
-
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs << "test"
|
8
|
-
t.libs << "lib"
|
9
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
-
end
|
11
|
-
|
12
|
-
require "rubocop/rake_task"
|
3
|
+
require "bundler/setup"
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
task default: %i[test rubocop]
|
5
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Bag Attributes
|
2
|
+
localKeyID: 0D BD D8 B5 3E 15 A0 F1 F6 25 9E 9B D6 01 A6 0B 0F BB DC 5C
|
3
|
+
Key Attributes: <No Attributes>
|
4
|
+
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
5
|
+
MIIFJDBWBgkqhkiG9w0BBQ0wSTAxBgkqhkiG9w0BBQwwJAQQzYI/YWH5XPd8Iw/3
|
6
|
+
rMFG0wICCAAwDAYIKoZIhvcNAgkFADAUBggqhkiG9w0DBwQI1c3P7SboACQEggTI
|
7
|
+
meakT/u5kwzbdwmfXI8lwxHlle4r8feP4SerRPFWVwEgLuEfkBiCP7lgSNwX1Tvy
|
8
|
+
szia9wM8qlx+aWCCUnvzUaGY6C9Tx07vef/HdY1Kh33558y2wjWcn2A0TBvT5RG0
|
9
|
+
oQAbKdhYP4+OZIQh3zngEzHIrXh28m4ewSYYqNBkq8NoWxALfiqQ9yrtPqqhP5YI
|
10
|
+
MPYsn9bG1hdEHnj/Ey1SbFDMDhIsEhGmQWgqym5fQHgQfHTSg86aZHhTliKZtu9m
|
11
|
+
uG5qtXzGm4L8W/YiRKXJHaKOB1UQ2NT91jQPXk5AVjmSlr2qOpZwBjpKPWFi5Zw9
|
12
|
+
XPZe2/wWbB72yHAEmHcMsxQnPib2DywMQb3A1czAm04oTorp0miCCq3y7VVom8UK
|
13
|
+
V25TOp1cP8h5rUKNwpUrJ5wm/xOYxGfUwLHLkcaE++bFrIlmUK+SQHsQAd2R8z/5
|
14
|
+
6MIlzmKq2ctB2jQZ+UpmYt39cBSG+FC8rDa96avGnp0uS2Pq5ss6XEihO2zQGuju
|
15
|
+
CiwIuZnmoy022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0vIQk
|
30
|
+
vIhCsF0jJIzyPaFa/fbdUMihJRfPe+uDRkbxufiWwZL9ApqyKzPj5UWz4Uit8/Re
|
31
|
+
5okF79w7sGGmgdRnugacg745zx3Iut7yl5Ivv6n65xmSg/vVFcMOgLYbYS86JsYH
|
32
|
+
/o16VJIexQtspdN1Li2EAJFMCgcZYO+l
|
33
|
+
-----END ENCRYPTED PRIVATE KEY-----
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Bag Attributes
|
2
|
+
localKeyID: 0D BD D8 B5 3E 15 A0 F1 F6 25 9E 9B D6 01 A6 0B 0F BB DC 5C
|
3
|
+
subject=C=SE, O=Testbank A AB (publ), serialNumber=5566304928, name=Test av BankID, CN=FP Testcert 5
|
4
|
+
issuer=C=SE, O=Testbank A AB (publ), serialNumber=111111111111, CN=Testbank A RP CA v1 for BankID Test
|
5
|
+
-----BEGIN CERTIFICATE-----
|
6
|
+
MIIEyjCCArKgAwIBAgIIG8/maByOzV4wDQYJKoZIhvcNAQELBQAwcTELMAkGA1UE
|
7
|
+
BhMCU0UxHTAbBgNVBAoMFFRlc3RiYW5rIEEgQUIgKHB1YmwpMRUwEwYDVQQFEwwx
|
8
|
+
MTExMTExMTExMTExLDAqBgNVBAMMI1Rlc3RiYW5rIEEgUlAgQ0EgdjEgZm9yIEJh
|
9
|
+
bmtJRCBUZXN0MB4XDTI0MDcwMjIyMDAwMFoXDTI5MDUyODIxNTk1OVowcjELMAkG
|
10
|
+
A1UEBhMCU0UxHTAbBgNVBAoMFFRlc3RiYW5rIEEgQUIgKHB1YmwpMRMwEQYDVQQF
|
11
|
+
Ewo1NTY2MzA0OTI4MRcwFQYDVQQpDA5UZXN0IGF2IEJhbmtJRDEWMBQGA1UEAwwN
|
12
|
+
RlAgVGVzdGNlcnQgNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANwG
|
13
|
+
Te3TokhAIefirshdT4vGAhoVLi04zgizezOWTbGp7ll6Jj41VFFg2An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XTFQifdSjYC0hOn9oLXnjg2ZtQremCym
|
29
|
+
3emqINt7LXTXb6qSscD5ZsTAkDqJ5WVgPLMimf8iHhvtTLvQE9b8c+FH6o1qzvV2
|
30
|
+
YnzfYGANQU2VUwN3jR8IfIAw/4kwgDURQQkgoqEq1JFowv7L2h//of5dOO7SCHuv
|
31
|
+
gH7GxzJbDS4wssRFBHZGpVgK6ZjyPmfemU/MuEnm
|
32
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
bankid:
|
3
|
+
hints:
|
4
|
+
cancelled: Action cancelled. Please try again.
|
5
|
+
alreadyInProgress: An identification or signing for this personal number is already started. Please try again.
|
6
|
+
requestTimeout: Internal error. Please try again.
|
7
|
+
maintenance: Internal error. Please try again.
|
8
|
+
userCancel: Action cancelled.
|
9
|
+
expiredTransaction: The BankID app is not responding. Please check that it’s started and that you have internet access. If you don’t have a valid BankID you can get one from your bank. Try again.
|
10
|
+
userSign: Enter your security code in the BankID app and select Identify or Sign.
|
11
|
+
outstandingTransaction: Trying to start your BankID app.
|
12
|
+
started: "Searching for BankID, it may take a little while. If a few seconds have passed and still no BankID has been found, you probably don’t have a BankID which can be used for this identification/signing on this computer. If you have a BankID card, please insert it into your card reader. If you don’t have a BankID you can get one from your bank. If you have a BankID on another device you can start the BankID app on that device."
|
13
|
+
certificateErr: The BankID you are trying to use is blocked or too old. Please use another BankID or get a new one from your bank.
|
14
|
+
startFailed: The BankID app couldn’t be found on your computer or mobile device. Please install it and get a BankID from your bank. Install the app from your app store or https://install.bankid.com.
|
15
|
+
userMrtd: Process your machine-readable travel document using the BankID app.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
sv:
|
2
|
+
bankid:
|
3
|
+
hints:
|
4
|
+
cancelled: Åtgärden avbruten. Försök igen.
|
5
|
+
alreadyInProgress: En identifiering eller underskrift för det här personnumret är redan påbörjad. Försök igen.
|
6
|
+
requestTimeout: Internt tekniskt fel. Försök igen.
|
7
|
+
maintenance: Internt tekniskt fel. Försök igen.
|
8
|
+
userCancel: Åtgärden avbruten.
|
9
|
+
expiredTransaction: BankID-appen svarar inte. Kontrollera att den är startad och att du har internetanslutning. Om du inte har något giltigt BankID kan du skaffa ett hos din bank. Försök sedan igen.
|
10
|
+
userSign: Skriv in din säkerhetskod i BankID-appen och välj Identifiera eller Skriv under.
|
11
|
+
outstandingTransaction: Försöker starta BankID-appen.
|
12
|
+
started: "Söker efter BankID, det kan ta en liten stund. Om det har gått några sekunder och inget BankID har hittats har du sannolikt inget BankID som går att använda för den aktuella identifieringen/underskriften i den här datorn. Om du har ett BankID-kort, sätt in det i kortläsaren. Om du inte har något BankID kan du skaffa ett hos din bank. Om du har ett BankID på en annan enhet kan du starta din BankID-app där."
|
13
|
+
certificateErr: Det BankID du försöker använda är för gammalt eller spärrat. Använd ett annat BankID eller skaffa ett nytt hos din bank.
|
14
|
+
startFailed: BankID-appen verkar inte finnas i din dator eller mobil. Installera den och skaffa ett BankID hos din bank. Installera appen från din appbutik eller https://install.bankid.com
|
15
|
+
userMrtd: Fotografera och läs av din ID-handling med BankID-appen.
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bankid
|
4
|
+
class Client
|
5
|
+
def initialize
|
6
|
+
@environment = Bankid.config.environment
|
7
|
+
raise EnvironmentNotSetError unless %i[development production].include?(@environment)
|
8
|
+
|
9
|
+
@url = @environment == :production ? Bankid::PRODUCTION_URL : Bankid::DEVELOPMENT_URL
|
10
|
+
@cert_password = Bankid.config.cert_password
|
11
|
+
@cert, @key, @root_cert = load_certificates
|
12
|
+
end
|
13
|
+
|
14
|
+
def auth(ip:, visible_data:)
|
15
|
+
request("auth", auth_data(ip:, visible_data:))
|
16
|
+
end
|
17
|
+
|
18
|
+
def cancel(id:)
|
19
|
+
request("cancel", orderRef: id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def sign(ip:, visible_data:)
|
23
|
+
request("sign", auth_data(ip:, visible_data:))
|
24
|
+
end
|
25
|
+
|
26
|
+
def collect(order_ref:)
|
27
|
+
request("collect", orderRef: order_ref)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def request(endpoint, data)
|
33
|
+
HTTP
|
34
|
+
.headers("Content-Type": "application/json")
|
35
|
+
.post("#{@url}/#{endpoint}", ssl_context:, json: data)
|
36
|
+
.parse
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth_data(ip:, visible_data:)
|
40
|
+
return { endUserIp: ip } if visible_data.nil?
|
41
|
+
|
42
|
+
{ endUserIp: ip, userVisibleData: Base64.encode64(visible_data) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def cert_path(file)
|
46
|
+
return File.absolute_path("./config/certs/#{file}") if @environment == :production
|
47
|
+
|
48
|
+
"#{Bundler.rubygems.find_name("bankid").first.full_gem_path}/config/certs/#{file}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def intermediate_path
|
52
|
+
file = "#{@environment}_bankid_certificate.pem"
|
53
|
+
"#{Bundler.rubygems.find_name("bankid").first.full_gem_path}/config/certs/#{file}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_certificates
|
57
|
+
[
|
58
|
+
OpenSSL::X509::Certificate.new(File.read(cert_path("client_certificate.pem"))),
|
59
|
+
OpenSSL::PKey::RSA.new(File.read(cert_path("client_certificate.key")), @cert_password),
|
60
|
+
OpenSSL::X509::Certificate.new(File.read(intermediate_path))
|
61
|
+
]
|
62
|
+
rescue Errno::ENOENT => _e
|
63
|
+
raise MissingCertificatesError
|
64
|
+
end
|
65
|
+
|
66
|
+
def ssl_context
|
67
|
+
OpenSSL::SSL::SSLContext.new.tap do |ctx|
|
68
|
+
ctx.add_certificate(
|
69
|
+
@cert,
|
70
|
+
@key,
|
71
|
+
[@root_cert]
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bankid
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
config.bankid = ActiveSupport::OrderedOptions.new
|
6
|
+
|
7
|
+
initializer "bankid" do |app|
|
8
|
+
Bankid.config = app.config.bankid
|
9
|
+
path = "#{Bundler.rubygems.find_name("bankid").first.full_gem_path}/config/locales/"
|
10
|
+
I18n.load_path += ["#{path}sv.yml", "#{path}en.yml"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bankid
|
4
|
+
class User
|
5
|
+
attr_accessor :personal_number, :name, :given_name, :surname
|
6
|
+
|
7
|
+
def initialize(personalNumber:, name:, givenName:, surname:)
|
8
|
+
@personal_number = personalNumber
|
9
|
+
@name = name
|
10
|
+
@given_name = givenName
|
11
|
+
@surname = surname
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Device
|
16
|
+
attr_accessor :device, :bankid_issue_date, :signature, :ocsp_response
|
17
|
+
|
18
|
+
def initialize(device:, signature:, ocspResponse:)
|
19
|
+
@device = device
|
20
|
+
@signature = signature
|
21
|
+
@ocsp_response = ocspResponse
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_json(*_args)
|
25
|
+
{ device:, signature:, ocsp_response: }.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Result
|
30
|
+
attr_accessor :user, :device, :hint_code
|
31
|
+
|
32
|
+
def initialize(result_json:)
|
33
|
+
@result_json = result_json
|
34
|
+
if result_json["status"] == "complete"
|
35
|
+
set_device_and_user
|
36
|
+
else
|
37
|
+
set_hint_code
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_device_and_user
|
42
|
+
@user = User.new(**@result_json.dig("completionData", "user").symbolize_keys)
|
43
|
+
@result_json["completionData"].symbolize_keys => {
|
44
|
+
device:,
|
45
|
+
signature:,
|
46
|
+
ocspResponse:
|
47
|
+
}
|
48
|
+
@device = Device.new(device:, signature:, ocspResponse:)
|
49
|
+
end
|
50
|
+
|
51
|
+
def set_hint_code
|
52
|
+
@hint_code = @result_json["hintCode"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def success?
|
56
|
+
@result_json["status"] == "complete"
|
57
|
+
end
|
58
|
+
|
59
|
+
def failure?
|
60
|
+
@result_json["status"] == "failed"
|
61
|
+
end
|
62
|
+
|
63
|
+
def pending?
|
64
|
+
@result_json["status"] == "pending"
|
65
|
+
end
|
66
|
+
|
67
|
+
def user_sign?
|
68
|
+
@result_json["status"] == "userSign"
|
69
|
+
end
|
70
|
+
|
71
|
+
def started?
|
72
|
+
@result_json["status"] == "started"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bankid
|
4
|
+
class Secret
|
5
|
+
RESOLUTION = 1
|
6
|
+
|
7
|
+
attr_reader :result, :order_ref
|
8
|
+
|
9
|
+
def initialize(orderRef:, autoStartToken:, qrStartToken:, qrStartSecret:, created_at:)
|
10
|
+
@order_ref = orderRef
|
11
|
+
@auto_start_token = autoStartToken
|
12
|
+
@qr_start_token = qrStartToken
|
13
|
+
@qr_start_secret = qrStartSecret
|
14
|
+
@created_at = created_at
|
15
|
+
end
|
16
|
+
|
17
|
+
def autostart_link(return_url = nil)
|
18
|
+
if return_url
|
19
|
+
"https://app.bankid.com/?autostarttoken=#{@auto_start_token}&redirect=#{return_url}"
|
20
|
+
else
|
21
|
+
"https://app.bankid.com/?autostarttoken=#{@auto_start_token}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def desktop_link(return_url)
|
26
|
+
"bankid:///?autostarttoken=#{@auto_start_token}&redirect=#{CGI.escape(return_url)}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def elapsed_seconds
|
30
|
+
((Time.zone.now - @created_at).to_f / RESOLUTION).floor * RESOLUTION
|
31
|
+
end
|
32
|
+
|
33
|
+
def qr_code
|
34
|
+
auth_code = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("SHA256"), @qr_start_secret, elapsed_seconds.to_s)
|
35
|
+
RQRCode::QRCode.new("bankid.#{@qr_start_token}.#{elapsed_seconds}.#{auth_code}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/bankid/version.rb
CHANGED
data/lib/bankid.rb
CHANGED
@@ -2,113 +2,56 @@
|
|
2
2
|
|
3
3
|
require "http"
|
4
4
|
require "rqrcode"
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
require "bankid/version"
|
6
|
+
require "bankid/client"
|
7
|
+
require "bankid/result"
|
8
|
+
require "bankid/secret"
|
9
|
+
require "bankid/railtie" if defined?(Rails::Railtie)
|
8
10
|
|
9
11
|
module Bankid
|
10
|
-
|
11
|
-
|
12
|
-
PRODUCTION_URL = "https://appapi2.bankid.com/rp/v5.1"
|
12
|
+
DEVELOPMENT_URL = "https://appapi2.test.bankid.com/rp/v6.0"
|
13
|
+
PRODUCTION_URL = "https://appapi2.bankid.com/rp/v6.0"
|
13
14
|
|
14
|
-
class
|
15
|
+
class EnvironmentNotSetError < StandardError; end
|
16
|
+
class MissingCertificatesError < StandardError; end
|
17
|
+
class CachedSecretNotFoundError < StandardError; end
|
18
|
+
class NoSuchOrderError < StandardError; end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@stubs[endpoint] = data
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.endpoint_stub(endpoint)
|
23
|
-
unless defined?(@stubs)
|
24
|
-
raise "You should stub the endpoint `#{endpoint}` with the `Bankid::Auth.stub_endpoint` method"
|
25
|
-
end
|
26
|
-
|
27
|
-
@stubs[endpoint]
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.clear_stubs
|
31
|
-
remove_instance_variable(:@stubs) if defined?(@stubs)
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize(env: "development", cert_password: "qwerty123")
|
35
|
-
@stubs = []
|
36
|
-
@env = env
|
37
|
-
@url = Bankid.const_get("#{env.upcase}_URL")
|
38
|
-
@cert_password = cert_password
|
39
|
-
@cert, @key, @root_cert = load_certificates
|
40
|
-
end
|
41
|
-
|
42
|
-
def generate_qr(start_token:, start_secret:, seconds:)
|
43
|
-
RQRCode::QRCode.new(
|
44
|
-
qr_auth_code(start_token, start_secret, seconds)
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def poll(order_ref:)
|
49
|
-
response = request("collect", { orderRef: order_ref })
|
50
|
-
Poll.new(**camelize(JSON.parse(response)))
|
51
|
-
end
|
52
|
-
|
53
|
-
def generate_authentication(ip:, id_number: nil)
|
54
|
-
response = request("auth", auth_data(ip, id_number))
|
55
|
-
Authentication.new(**camelize(JSON.parse(response)))
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def request(endpoint, data)
|
61
|
-
return Auth.endpoint_stub(endpoint) if @env == "test"
|
62
|
-
|
63
|
-
HTTP
|
64
|
-
.headers("Content-Type": "application/json")
|
65
|
-
.post("#{@url}/#{endpoint}", ssl_context: ssl_context, json: data).to_s
|
66
|
-
end
|
67
|
-
|
68
|
-
def auth_data(ip, id_number)
|
69
|
-
{ endUserIp: ip }.merge(id_number ? { id_number: id_number } : {})
|
70
|
-
end
|
20
|
+
def self.config
|
21
|
+
@@config
|
22
|
+
end
|
71
23
|
|
72
|
-
|
73
|
-
|
74
|
-
|
24
|
+
def self.config=(config)
|
25
|
+
@@config = config
|
26
|
+
end
|
75
27
|
|
76
|
-
|
77
|
-
|
78
|
-
|
28
|
+
def self.cancel(id)
|
29
|
+
Client.new.cancel(id:)
|
30
|
+
end
|
79
31
|
|
80
|
-
|
81
|
-
|
32
|
+
def self.collect(id)
|
33
|
+
cached_secret = Rails.cache.read(id)
|
34
|
+
raise CachedSecretNotFoundError if cached_secret.nil?
|
82
35
|
|
83
|
-
|
84
|
-
|
85
|
-
OpenSSL::PKey::RSA.new(File.read(cert_path("client_certificate.key")), @cert_password),
|
86
|
-
OpenSSL::X509::Certificate.new(File.read(cert_path("bankid_certificate.pem")))
|
87
|
-
]
|
88
|
-
end
|
36
|
+
result_json = Client.new.collect(order_ref: id)
|
37
|
+
raise NoSuchOrderError if result_json["errorCode"].present?
|
89
38
|
|
90
|
-
|
91
|
-
|
39
|
+
[Secret.new(**cached_secret.symbolize_keys), Result.new(result_json:)]
|
40
|
+
end
|
92
41
|
|
93
|
-
|
94
|
-
|
42
|
+
def self.generate_authentication(ip:, visible_data: nil)
|
43
|
+
response = Client.new.auth(ip:, visible_data:).merge(created_at: Time.zone.now)
|
44
|
+
Rails.cache.write(response["orderRef"], response, expires_in: 1.minute)
|
45
|
+
response["orderRef"]
|
46
|
+
end
|
95
47
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
[@root_cert]
|
102
|
-
)
|
103
|
-
end
|
104
|
-
end
|
48
|
+
def self.generate_signature(ip:, visible_data: nil)
|
49
|
+
response = Client.new.sign(ip:, visible_data:).merge(created_at: Time.zone.now)
|
50
|
+
Rails.cache.write(response["orderRef"], response, expires_in: 1.minute)
|
51
|
+
response["orderRef"]
|
52
|
+
end
|
105
53
|
|
106
|
-
|
107
|
-
|
108
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
109
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
110
|
-
.tr("-", "_")
|
111
|
-
.downcase
|
112
|
-
end
|
54
|
+
def self.translated_hint_code(hint_code)
|
55
|
+
I18n.translate("bankid.hints.#{hint_code}")
|
113
56
|
end
|
114
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan Halse
|
8
|
-
|
9
|
-
bindir: exe
|
8
|
+
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: http
|
@@ -16,28 +15,42 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
18
|
+
version: 5.1.1
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.
|
25
|
+
version: 5.1.1
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rails
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 7.0.0
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: rqrcode
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
30
43
|
requirements:
|
31
44
|
- - "~>"
|
32
45
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
46
|
+
version: 2.2.0
|
34
47
|
type: :runtime
|
35
48
|
prerelease: false
|
36
49
|
version_requirements: !ruby/object:Gem::Requirement
|
37
50
|
requirements:
|
38
51
|
- - "~>"
|
39
52
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
53
|
+
version: 2.2.0
|
41
54
|
description: A simple and easy way to add Swedish BankID QR code login to your site.
|
42
55
|
email:
|
43
56
|
- johan@hal.se
|
@@ -45,24 +58,23 @@ executables: []
|
|
45
58
|
extensions: []
|
46
59
|
extra_rdoc_files: []
|
47
60
|
files:
|
48
|
-
-
|
49
|
-
- CHANGELOG.md
|
50
|
-
- Gemfile
|
51
|
-
- Gemfile.lock
|
52
|
-
- LICENSE.txt
|
61
|
+
- MIT-LICENSE
|
53
62
|
- README.md
|
54
63
|
- Rakefile
|
55
|
-
-
|
56
|
-
-
|
64
|
+
- config/certs/client_certificate.key
|
65
|
+
- config/certs/client_certificate.p12
|
66
|
+
- config/certs/client_certificate.pem
|
57
67
|
- config/certs/development_bankid_certificate.pem
|
58
|
-
- config/certs/development_client_certificate.key
|
59
|
-
- config/certs/development_client_certificate.p12
|
60
|
-
- config/certs/development_client_certificate.pem
|
61
68
|
- config/certs/production_bankid_certificate.pem
|
69
|
+
- config/locales/en.yml
|
70
|
+
- config/locales/sv.yml
|
62
71
|
- lib/bankid.rb
|
63
|
-
- lib/bankid/
|
64
|
-
- lib/bankid/
|
72
|
+
- lib/bankid/client.rb
|
73
|
+
- lib/bankid/railtie.rb
|
74
|
+
- lib/bankid/result.rb
|
75
|
+
- lib/bankid/secret.rb
|
65
76
|
- lib/bankid/version.rb
|
77
|
+
- lib/tasks/bankid_tasks.rake
|
66
78
|
homepage: https://github.com/johanhalse/bankid
|
67
79
|
licenses:
|
68
80
|
- MIT
|
@@ -72,7 +84,6 @@ metadata:
|
|
72
84
|
source_code_uri: https://github.com/johanhalse/bankid
|
73
85
|
changelog_uri: https://github.com/johanhalse/bankid/CHANGELOG.md
|
74
86
|
rubygems_mfa_required: 'true'
|
75
|
-
post_install_message:
|
76
87
|
rdoc_options: []
|
77
88
|
require_paths:
|
78
89
|
- lib
|
@@ -80,15 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
91
|
requirements:
|
81
92
|
- - ">="
|
82
93
|
- !ruby/object:Gem::Version
|
83
|
-
version: 3.
|
94
|
+
version: 3.3.0
|
84
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
96
|
requirements:
|
86
97
|
- - ">="
|
87
98
|
- !ruby/object:Gem::Version
|
88
99
|
version: '0'
|
89
100
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
101
|
+
rubygems_version: 3.7.1
|
92
102
|
specification_version: 4
|
93
103
|
summary: BankID authentication for Ruby.
|
94
104
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 3.0.2
|
3
|
-
NewCops: enable
|
4
|
-
Exclude:
|
5
|
-
- "bin/**/*"
|
6
|
-
- "public/**/*"
|
7
|
-
- "log/**/*"
|
8
|
-
- "tmp/**/*"
|
9
|
-
- "vendor/**/*"
|
10
|
-
- "db/schema.rb"
|
11
|
-
- "db/migrate/**/*"
|
12
|
-
|
13
|
-
Layout/LineLength:
|
14
|
-
Max: 120
|
15
|
-
|
16
|
-
Metrics/AbcSize:
|
17
|
-
Max: 20
|
18
|
-
|
19
|
-
Metrics/MethodLength:
|
20
|
-
Max: 16
|
21
|
-
|
22
|
-
Metrics/BlockLength:
|
23
|
-
Max: 30
|
24
|
-
|
25
|
-
Style/Documentation:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Style/StringLiterals:
|
29
|
-
Enabled: true
|
30
|
-
EnforcedStyle: double_quotes
|
31
|
-
|
32
|
-
Style/StringLiteralsInInterpolation:
|
33
|
-
Enabled: true
|
34
|
-
EnforcedStyle: double_quotes
|
data/CHANGELOG.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
## [Unreleased]
|
2
|
-
|
3
|
-
## [1.0.1] - 2022-12-11
|
4
|
-
|
5
|
-
- Include new development client certificate instead of the old expired one
|
6
|
-
|
7
|
-
## [1.0.0] - 2022-09-30
|
8
|
-
|
9
|
-
- Deprecate the `PKCS12` algorithm in favor of `X509`: [issue #3](https://github.com/johanhalse/bankid/issues/3)
|
10
|
-
|
11
|
-
## [0.1.2] - 2022-09-08
|
12
|
-
|
13
|
-
- Add `pending?` method call for poll response object
|
14
|
-
|
15
|
-
## [0.1.1] - 2022-04-06
|
16
|
-
|
17
|
-
- Make Poll object accept error codes and details from [errors](https://www.bankid.com/utvecklare/guider/teknisk-integrationsguide/graenssnittsbeskrivning/felfall)
|
18
|
-
|
19
|
-
## [0.1.0] - 2021-10-25
|
20
|
-
|
21
|
-
- Initial release
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bankid (0.1.2)
|
5
|
-
http (~> 5.0.4)
|
6
|
-
rqrcode (~> 2.1.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.8.0)
|
12
|
-
public_suffix (>= 2.0.2, < 5.0)
|
13
|
-
ast (2.4.2)
|
14
|
-
chunky_png (1.4.0)
|
15
|
-
coderay (1.1.3)
|
16
|
-
crack (0.4.5)
|
17
|
-
rexml
|
18
|
-
domain_name (0.5.20190701)
|
19
|
-
unf (>= 0.0.5, < 1.0.0)
|
20
|
-
ffi (1.15.5)
|
21
|
-
ffi-compiler (1.0.1)
|
22
|
-
ffi (>= 1.0.0)
|
23
|
-
rake
|
24
|
-
hashdiff (1.0.1)
|
25
|
-
http (5.0.4)
|
26
|
-
addressable (~> 2.8)
|
27
|
-
http-cookie (~> 1.0)
|
28
|
-
http-form_data (~> 2.2)
|
29
|
-
llhttp-ffi (~> 0.4.0)
|
30
|
-
http-cookie (1.0.5)
|
31
|
-
domain_name (~> 0.5)
|
32
|
-
http-form_data (2.3.0)
|
33
|
-
llhttp-ffi (0.4.0)
|
34
|
-
ffi-compiler (~> 1.0)
|
35
|
-
rake (~> 13.0)
|
36
|
-
method_source (1.0.0)
|
37
|
-
minitest (5.15.0)
|
38
|
-
parallel (1.21.0)
|
39
|
-
parser (3.1.0.0)
|
40
|
-
ast (~> 2.4.1)
|
41
|
-
pry (0.14.1)
|
42
|
-
coderay (~> 1.1)
|
43
|
-
method_source (~> 1.0)
|
44
|
-
public_suffix (4.0.6)
|
45
|
-
rainbow (3.1.1)
|
46
|
-
rake (13.0.6)
|
47
|
-
regexp_parser (2.2.0)
|
48
|
-
rexml (3.2.5)
|
49
|
-
rqrcode (2.1.2)
|
50
|
-
chunky_png (~> 1.0)
|
51
|
-
rqrcode_core (~> 1.0)
|
52
|
-
rqrcode_core (1.2.0)
|
53
|
-
rubocop (1.25.1)
|
54
|
-
parallel (~> 1.10)
|
55
|
-
parser (>= 3.1.0.0)
|
56
|
-
rainbow (>= 2.2.2, < 4.0)
|
57
|
-
regexp_parser (>= 1.8, < 3.0)
|
58
|
-
rexml
|
59
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
60
|
-
ruby-progressbar (~> 1.7)
|
61
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
62
|
-
rubocop-ast (1.15.1)
|
63
|
-
parser (>= 3.0.1.1)
|
64
|
-
ruby-progressbar (1.11.0)
|
65
|
-
unf (0.1.4)
|
66
|
-
unf_ext
|
67
|
-
unf_ext (0.0.8.2)
|
68
|
-
unicode-display_width (2.1.0)
|
69
|
-
webmock (3.14.0)
|
70
|
-
addressable (>= 2.8.0)
|
71
|
-
crack (>= 0.3.2)
|
72
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
73
|
-
|
74
|
-
PLATFORMS
|
75
|
-
x86_64-linux
|
76
|
-
|
77
|
-
DEPENDENCIES
|
78
|
-
bankid!
|
79
|
-
minitest
|
80
|
-
pry
|
81
|
-
rake
|
82
|
-
rubocop
|
83
|
-
webmock
|
84
|
-
|
85
|
-
BUNDLED WITH
|
86
|
-
2.2.28
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2021 Johan Halse
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "bankid"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
Bag Attributes
|
2
|
-
localKeyID: A9 F3 0C D7 04 B6 7D 23 86 84 71 C3 E9 42 62 8B 1B D7 75 C3
|
3
|
-
Key Attributes: <No Attributes>
|
4
|
-
-----BEG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6 7D 23 86 84 71 C3 E9 42 62 8B 1B D7 75 C3
|
3
|
-
subject=C = SE, O = Testbank A AB (publ), serialNumber = 5566304928, name = Test av BankID, CN = FP Testcert 4
|
4
|
-
issuer=C = SE, O = Testbank A AB (publ), serialNumber = 111111111111, CN = Testbank A RP CA v1 for BankID Test
|
5
|
-
-----BEGIN CERTIFICATE-----
|
6
|
-
MIIEyjCCArKgAwIBAgIIMLbIMaRHjMMwDQYJKoZIhvcNAQELBQAwcTELMAkGA1UE
|
7
|
-
BhMCU0UxHTAbBgNVBAoMFFRlc3RiYW5rIEEgQUIgKHB1YmwpMRUwEwYDVQQFEwwx
|
8
|
-
MTExMTExMTExMTExLDAqBgNVBAMMI1Rlc3RiYW5rIEEgUlAgQ0EgdjEgZm9yIEJh
|
9
|
-
bmtJRCBUZXN0MB4XDTIyMDgxNzIyMDAwMFoXDTI0MDgxODIxNTk1OVowcjELMAkG
|
10
|
-
A1UEBhMCU0UxHTAbBgNVBAoMFFRlc3RiYW5rIEEgQUIgKHB1YmwpMRMwEQYDVQQF
|
11
|
-
Ewo1NTY2MzA0OTI4MRcwFQYDVQQpDA5UZXN0IGF2IEJhbmtJRDEWMBQGA1UEAwwN
|
12
|
-
RlAgVGVzdGNlcnQgNDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL4L
|
13
|
-
8ERHNSi7Jph9gj4ah7Ieok5lZHZbNyW1AiJJ1OfeD1lbAzxSidtTu6NfC83zxCjL
|
14
|
-
q091lHY5G7dpNDt1rN5Y+jQvrtcLc8nUpgqLfEUnbGKzZaHlO97jh6pqO8nj/mal
|
15
|
-
TrWI70Fr6SO3SxbsgxuwJXlRUAQxI0mPvD1gOd+uymA+EqdYS39ijC2eICHSf7bU
|
16
|
-
wvmscy8TAyEcT4GYmcjai1vbIjlhemmAv+NKJiSpD+zqvuHGIzBm71/Fd6cTAXqk
|
17
|
-
HkqTlJsxF2m6eojKCfcm5uAvSTXhVbGM155wmpzLskzkQ0dx6L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
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bankid
|
4
|
-
class Authentication
|
5
|
-
ATTRS = %i[order_ref auto_start_token qr_start_token qr_start_secret].freeze
|
6
|
-
attr_accessor(*ATTRS)
|
7
|
-
|
8
|
-
def initialize(order_ref:, auto_start_token:, qr_start_token:, qr_start_secret:)
|
9
|
-
@order_ref = order_ref
|
10
|
-
@auto_start_token = auto_start_token
|
11
|
-
@qr_start_token = qr_start_token
|
12
|
-
@qr_start_secret = qr_start_secret
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_h
|
16
|
-
ATTRS.to_h { |a| [a, send(a)] }
|
17
|
-
end
|
18
|
-
|
19
|
-
def ==(other)
|
20
|
-
ATTRS.all? { |a| send(a) == other.send(a) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/bankid/poll.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bankid
|
4
|
-
class Poll
|
5
|
-
ATTRS = %i[order_ref status hint_code completion_data error_code details].freeze
|
6
|
-
attr_accessor(*ATTRS)
|
7
|
-
|
8
|
-
# rubocop:disable Metrics/ParameterLists
|
9
|
-
def initialize(order_ref: nil, status: nil, hint_code: nil, completion_data: {}, error_code: nil, details: nil)
|
10
|
-
@order_ref = order_ref
|
11
|
-
@status = status
|
12
|
-
@hint_code = hint_code
|
13
|
-
@completion_data = completion_data
|
14
|
-
@error_code = error_code
|
15
|
-
@details = details
|
16
|
-
end
|
17
|
-
# rubocop:enable Metrics/ParameterLists
|
18
|
-
|
19
|
-
def completed?
|
20
|
-
status == "complete"
|
21
|
-
end
|
22
|
-
|
23
|
-
def failed?
|
24
|
-
status == "failed" || error_code
|
25
|
-
end
|
26
|
-
|
27
|
-
def pending?
|
28
|
-
status == "pending"
|
29
|
-
end
|
30
|
-
|
31
|
-
def timed_out?
|
32
|
-
hint_code == "startFailed"
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_h
|
36
|
-
ATTRS.to_h { |a| [a, send(a)] }
|
37
|
-
end
|
38
|
-
|
39
|
-
def ==(other)
|
40
|
-
ATTRS.all? { |a| send(a) == other.send(a) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|