ruby_isds 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.overcommit.yml +2 -0
- data/Gemfile.lock +2 -2
- data/README.md +30 -1
- data/lib/ruby_isds.rb +1 -0
- data/lib/ruby_isds/configuration.rb +32 -3
- data/lib/ruby_isds/data_box.rb +4 -0
- data/lib/ruby_isds/request.rb +14 -1
- data/lib/ruby_isds/response.rb +1 -0
- data/lib/ruby_isds/utils/errors.rb +8 -0
- data/lib/ruby_isds/version.rb +1 -1
- data/lib/ruby_isds/web_services/db_access/get_owner_info_from_login.rb +19 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2499d07ffdb8aefc294f1de7201ef0c5fcee34d8b44575647b09db11feae1227
|
4
|
+
data.tar.gz: fb64e99eb613497520fb797e2d0896c0639a4caef968dbae09c1668845491e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abedc2bfcf4857ec5ac33936f6597d18ad24a59b1013b7c37ebe05a5fb1c5ba067d6059c8c4af0ef0bde990147622128d92a0c468efc496935720674d3ef0dec
|
7
|
+
data.tar.gz: d8dc750bbfbc8f7bf2ad59d10f7d0c7b07757dca0d649c999bac4b3a53f5760eb605ca927b4dd589e2f95c0659f9ba1cf5a5d47a87688f9d2db753a89e0b7a89
|
data/.gitignore
CHANGED
data/.overcommit.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,10 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Before usage please add config (for rails initializer) with
|
25
|
+
Before usage please add config (for rails initializer) with one of supported
|
26
|
+
auth strategies:
|
27
|
+
|
28
|
+
### Username + password
|
26
29
|
|
27
30
|
```ruby
|
28
31
|
RubyIsds.configure do |c|
|
@@ -32,6 +35,19 @@ RubyIsds.configure do |c|
|
|
32
35
|
c.env = :development
|
33
36
|
end
|
34
37
|
```
|
38
|
+
### Server side system certificate
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
RubyIsds.configure do |c|
|
42
|
+
c.data_box = 'data_box_id'
|
43
|
+
c.cert_file = 'spec/factories/files/certifikat.pem'
|
44
|
+
c.key_file = 'spec/factories/files/test-key.key'
|
45
|
+
c.pass_phrase = 'andrej'
|
46
|
+
c.env = :development
|
47
|
+
end
|
48
|
+
```
|
49
|
+
here `data_box_id` if id of databox you will be accessing, you do not really
|
50
|
+
need id of databox used as point from where you access
|
35
51
|
|
36
52
|
you do not have to provide `env` in setup unless you go to production, gem
|
37
53
|
defaults to `:development` anyway...
|
@@ -220,6 +236,19 @@ TODO
|
|
220
236
|
|
221
237
|
If in doubt, or my so called 'README' seems not that helpful, please refer to [ISDS provozni rad](https://www.datoveschranky.info/dulezite-informace/provozni-rad-isds)
|
222
238
|
|
239
|
+
#### Certificates
|
240
|
+
|
241
|
+
Just some helpfull information when you want to use certificate to access
|
242
|
+
databoxes:
|
243
|
+
|
244
|
+
How to setup and what not in ISDS: [https://www.czebox.cz/static/ISDS/help/page8.html#8_4](https://www.czebox.cz/static/ISDS/help/page8.html#8_4)
|
245
|
+
|
246
|
+
Working with DER/PEM and what not around the keys: [https://knowledge.digicert.com/solution/SO26449.html](https://knowledge.digicert.com/solution/SO26449.html)
|
247
|
+
|
248
|
+
How to convert windows pfx file exported from keychain into key you need here: [https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/](https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/)
|
249
|
+
|
250
|
+
Jus to note here, certificate accepted should be in PEM format and you have to add the private.key with the password to it.
|
251
|
+
|
223
252
|
## Development
|
224
253
|
|
225
254
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/ruby_isds.rb
CHANGED
@@ -41,6 +41,7 @@ require 'ruby_isds/web_services/db_search/p_d_z_info'
|
|
41
41
|
require 'ruby_isds/web_services/db_search/p_d_z_send_info'
|
42
42
|
|
43
43
|
require 'ruby_isds/web_services/db_access/change_isds_password'
|
44
|
+
require 'ruby_isds/web_services/db_access/get_owner_info_from_login'
|
44
45
|
|
45
46
|
require 'ruby_isds/web_services/dm_info/request'
|
46
47
|
require 'ruby_isds/web_services/dm_info/response'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module RubyIsds
|
2
2
|
class Configuration
|
3
|
-
attr_writer :data_box, :username, :password, :env, :api_url
|
3
|
+
attr_writer :data_box, :username, :password, :env, :api_url,
|
4
|
+
:cert_file, :key_file, :pass_phrase
|
5
|
+
attr_reader :pass_phrase
|
4
6
|
|
5
7
|
ALLOWED_PRODUCTION_SYNTAX = [:production, 'production'].freeze
|
6
8
|
|
@@ -9,6 +11,9 @@ module RubyIsds
|
|
9
11
|
@password = nil
|
10
12
|
@data_box = nil
|
11
13
|
@env = nil
|
14
|
+
@cert_file = nil
|
15
|
+
@key_file = nil
|
16
|
+
@pass_phrase = nil
|
12
17
|
end
|
13
18
|
|
14
19
|
def data_box
|
@@ -26,6 +31,25 @@ module RubyIsds
|
|
26
31
|
@password
|
27
32
|
end
|
28
33
|
|
34
|
+
def cert_file
|
35
|
+
if @cert_file && (!@key_file && !@pass_phrase)
|
36
|
+
raise ConfigNotSet, 'pass_phrase and key_file'
|
37
|
+
end
|
38
|
+
return unless @cert_file
|
39
|
+
OpenSSL::X509::Certificate.new(File.read(@cert_file))
|
40
|
+
end
|
41
|
+
|
42
|
+
def key_file
|
43
|
+
return nil unless @key_file
|
44
|
+
File.read(@key_file)
|
45
|
+
end
|
46
|
+
|
47
|
+
def private_key
|
48
|
+
raise ConfigNotSet, 'pass_phrase' if @key_file && !@pass_phrase
|
49
|
+
raise ConfigNotSet, 'key_file' if !@key_file && @pass_phrase
|
50
|
+
OpenSSL::PKey::RSA.new(File.read(@key_file), @pass_phrase)
|
51
|
+
end
|
52
|
+
|
29
53
|
##
|
30
54
|
# env values:
|
31
55
|
# :development (default)
|
@@ -37,8 +61,13 @@ module RubyIsds
|
|
37
61
|
end
|
38
62
|
|
39
63
|
def api_domain
|
40
|
-
|
41
|
-
|
64
|
+
if production?
|
65
|
+
return 'https://ws1c.mojedatovaschranka.cz/cert' if @cert_file
|
66
|
+
'https://ws1.mojedatovaschranka.cz'
|
67
|
+
else
|
68
|
+
return 'https://ws1c.czebox.cz/hspis' if @cert_file
|
69
|
+
'https://ws1.czebox.cz'
|
70
|
+
end
|
42
71
|
end
|
43
72
|
|
44
73
|
def xml_url
|
data/lib/ruby_isds/data_box.rb
CHANGED
@@ -10,6 +10,10 @@ module RubyIsds
|
|
10
10
|
.call(options)
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.owner_info
|
14
|
+
::RubyIsds::WebServices::DbAccess::GetOwnerInfoFromLogin.call
|
15
|
+
end
|
16
|
+
|
13
17
|
def self.credit_info(options = {})
|
14
18
|
::RubyIsds::WebServices::DbSearch::DataBoxCreditInfo
|
15
19
|
.call(options.merge(dbID: ::RubyIsds.configuration.data_box))
|
data/lib/ruby_isds/request.rb
CHANGED
@@ -11,20 +11,33 @@ module RubyIsds
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# rubocop:disable Metrics/AbcSize
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
14
15
|
def call
|
15
16
|
uri = URI(full_url)
|
16
17
|
|
17
18
|
request = Net::HTTP::Post.new(uri)
|
18
19
|
default_headers.each { |k, v| request[k] = v }
|
19
20
|
request.body = to_xml
|
20
|
-
request.basic_auth RubyIsds.configuration.username, RubyIsds.configuration.password
|
21
21
|
|
22
22
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
23
23
|
https.use_ssl = true
|
24
24
|
https.ssl_version = :TLSv1_2_client
|
25
|
+
if RubyIsds.configuration.cert_file
|
26
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
27
|
+
https.cert = RubyIsds.configuration.cert_file
|
28
|
+
https.key = RubyIsds.configuration.private_key
|
29
|
+
https.verify_depth = 5
|
30
|
+
request.basic_auth(RubyIsds.configuration.data_box, '')
|
31
|
+
else
|
32
|
+
request.basic_auth(
|
33
|
+
RubyIsds.configuration.username,
|
34
|
+
RubyIsds.configuration.password
|
35
|
+
)
|
36
|
+
end
|
25
37
|
response = https.request(request)
|
26
38
|
call_reponse_wrapper(response)
|
27
39
|
end
|
40
|
+
# rubocop:enable Metrics/MethodLength
|
28
41
|
# rubocop:enable Metrics/AbcSize
|
29
42
|
|
30
43
|
def call_reponse_wrapper(response)
|
data/lib/ruby_isds/response.rb
CHANGED
data/lib/ruby_isds/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module RubyIsds
|
2
|
+
module WebServices
|
3
|
+
module DbAccess
|
4
|
+
class GetOwnerInfoFromLogin < ::RubyIsds::WebServices::DbSearch::Request
|
5
|
+
ATTRS = [].freeze
|
6
|
+
|
7
|
+
attr_accessor(*ATTRS)
|
8
|
+
|
9
|
+
def body(xml)
|
10
|
+
xml[:v20].GetOwnerInfoFromLogin {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_url
|
14
|
+
'/DS/DsManage'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_isds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrej Antas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- lib/ruby_isds/version.rb
|
239
239
|
- lib/ruby_isds/web_services/db_access/.gitkeep
|
240
240
|
- lib/ruby_isds/web_services/db_access/change_isds_password.rb
|
241
|
+
- lib/ruby_isds/web_services/db_access/get_owner_info_from_login.rb
|
241
242
|
- lib/ruby_isds/web_services/db_search/check_data_box.rb
|
242
243
|
- lib/ruby_isds/web_services/db_search/d_t_info.rb
|
243
244
|
- lib/ruby_isds/web_services/db_search/data_box_credit_info.rb
|
@@ -295,8 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
296
|
- !ruby/object:Gem::Version
|
296
297
|
version: '0'
|
297
298
|
requirements: []
|
298
|
-
|
299
|
-
rubygems_version: 2.7.7
|
299
|
+
rubygems_version: 3.0.2
|
300
300
|
signing_key:
|
301
301
|
specification_version: 4
|
302
302
|
summary: Ruby client to access ISDS
|