istox 0.1.57 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -18
- data/README.md +2 -4
- data/istox.gemspec +2 -2
- data/lib/istox.rb +2 -1
- data/lib/istox/helpers/gruf_listener_hook.rb +21 -0
- data/lib/istox/version.rb +1 -1
- metadata +18 -18
- data/lib/istox/helpers/vault.rb +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d76f139bc204f75de31580c218d9bc5261b62f73ae56d7296510ce9e74fbf8b
|
4
|
+
data.tar.gz: b63f7d722ef5441ba09e7dd659587f6a4a1b217ed5eb376346895f3df265d754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 447446bba295270c40b16fef8be8ea2ac8a2016cac58eee414c3bf57988bf3ccba32f15fa9910da5cb47689c8bacaf0e850f51dace9dab151bb9fa45c1fce023
|
7
|
+
data.tar.gz: 8316a7fac0f570e3a868c86c4772228e4653a0ababdb64ac222da3d0e68c93fbe94359be1c506bc2d6f9c1ea137091b86748a640f42002a5046eca8d6524948c
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.1.
|
4
|
+
istox (0.1.48.5)
|
5
5
|
bunny (>= 2.12.0)
|
6
6
|
graphlient
|
7
|
-
|
7
|
+
istox_gruf
|
8
|
+
listen (~> 3.0.5)
|
8
9
|
paranoia (~> 2.2)
|
9
10
|
|
10
11
|
GEM
|
@@ -57,7 +58,7 @@ GEM
|
|
57
58
|
bullet (5.7.6)
|
58
59
|
activesupport (>= 3.0.0)
|
59
60
|
uniform_notifier (~> 1.11.0)
|
60
|
-
bunny (2.14.
|
61
|
+
bunny (2.14.2)
|
61
62
|
amq-protocol (~> 2.3, >= 2.3.0)
|
62
63
|
concurrent-ruby (1.1.4)
|
63
64
|
crass (1.0.4)
|
@@ -75,31 +76,35 @@ GEM
|
|
75
76
|
multipart-post (>= 1.2, < 3)
|
76
77
|
faraday_middleware (0.13.1)
|
77
78
|
faraday (>= 0.7.4, < 1.0)
|
79
|
+
ffi (1.11.1)
|
78
80
|
globalid (0.4.2)
|
79
81
|
activesupport (>= 4.2.0)
|
80
|
-
google-protobuf (3.
|
81
|
-
googleapis-common-protos-types (1.0.
|
82
|
+
google-protobuf (3.8.0)
|
83
|
+
googleapis-common-protos-types (1.0.4)
|
82
84
|
google-protobuf (~> 3.0)
|
83
85
|
graphlient (0.3.5)
|
84
86
|
faraday
|
85
87
|
faraday_middleware
|
86
88
|
graphql-client
|
87
|
-
graphql (1.9.
|
89
|
+
graphql (1.9.6)
|
88
90
|
graphql-client (0.14.0)
|
89
91
|
activesupport (>= 3.0, < 6.0)
|
90
92
|
graphql (~> 1.6)
|
91
|
-
grpc (1.
|
92
|
-
google-protobuf (~> 3.
|
93
|
-
googleapis-common-protos-types (~> 1.0
|
94
|
-
grpc-tools (1.
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
grpc (1.21.0)
|
94
|
+
google-protobuf (~> 3.7)
|
95
|
+
googleapis-common-protos-types (~> 1.0)
|
96
|
+
grpc-tools (1.21.0)
|
97
|
+
i18n (0.9.5)
|
98
|
+
concurrent-ruby (~> 1.0)
|
99
|
+
istox_gruf (2.7.1)
|
100
|
+
activesupport (> 4)
|
101
|
+
concurrent-ruby (> 1)
|
98
102
|
grpc (~> 1.10)
|
99
103
|
grpc-tools (~> 1.10)
|
100
104
|
slop (~> 4.6)
|
101
|
-
|
102
|
-
|
105
|
+
listen (3.0.8)
|
106
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
107
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
103
108
|
loofah (2.2.3)
|
104
109
|
crass (~> 1.0.2)
|
105
110
|
nokogiri (>= 1.5.9)
|
@@ -112,12 +117,12 @@ GEM
|
|
112
117
|
mini_mime (1.0.1)
|
113
118
|
mini_portile2 (2.4.0)
|
114
119
|
minitest (5.11.3)
|
115
|
-
multipart-post (2.
|
120
|
+
multipart-post (2.1.1)
|
116
121
|
nio4r (2.3.1)
|
117
122
|
nokogiri (1.10.1)
|
118
123
|
mini_portile2 (~> 2.4.0)
|
119
|
-
paranoia (2.4.
|
120
|
-
activerecord (>= 4.0, <
|
124
|
+
paranoia (2.4.2)
|
125
|
+
activerecord (>= 4.0, < 6.1)
|
121
126
|
rack (2.0.6)
|
122
127
|
rack-test (1.1.0)
|
123
128
|
rack (>= 1.0, < 3)
|
@@ -146,6 +151,9 @@ GEM
|
|
146
151
|
rake (>= 0.8.7)
|
147
152
|
thor (>= 0.19.0, < 2.0)
|
148
153
|
rake (10.5.0)
|
154
|
+
rb-fsevent (0.10.3)
|
155
|
+
rb-inotify (0.10.0)
|
156
|
+
ffi (~> 1.0)
|
149
157
|
rspec (3.8.0)
|
150
158
|
rspec-core (~> 3.8.0)
|
151
159
|
rspec-expectations (~> 3.8.0)
|
data/README.md
CHANGED
data/istox.gemspec
CHANGED
@@ -32,10 +32,10 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_dependency "bunny", ">= 2.12.0"
|
35
|
-
spec.add_dependency "
|
36
|
-
spec.add_dependency 'vault', '~> 0.1'
|
35
|
+
spec.add_dependency "istox_gruf"
|
37
36
|
spec.add_dependency "paranoia", "~> 2.2"
|
38
37
|
spec.add_dependency "graphlient"
|
38
|
+
spec.add_dependency 'listen', '~> 3.0.5'
|
39
39
|
spec.add_development_dependency "bundler", "~> 1.16"
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/lib/istox.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'paranoia'
|
3
|
+
require "gruf"
|
3
4
|
require "istox/version"
|
4
5
|
|
5
6
|
module Istox
|
@@ -13,10 +14,10 @@ module Istox
|
|
13
14
|
require "istox/interfaces/chainhub/transaction"
|
14
15
|
require "istox/helpers/publisher"
|
15
16
|
require "istox/helpers/bunny_boot"
|
16
|
-
require "istox/helpers/vault"
|
17
17
|
require "istox/helpers/order_book"
|
18
18
|
require "istox/helpers/grpc_client"
|
19
19
|
require "istox/helpers/graphql_client"
|
20
|
+
require "istox/helpers/gruf_listener_hook"
|
20
21
|
require "istox/helpers/message_service"
|
21
22
|
require "istox/helpers/blockchain_receipt_service"
|
22
23
|
require "istox/models/blockchain_receipt"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Istox
|
2
|
+
class GrufListenerHook < ::Gruf::Hooks::Base
|
3
|
+
def before_server_start(server:)
|
4
|
+
# do my thing before the server starts
|
5
|
+
|
6
|
+
@listener = Listen.to('app/rpc') do |modified, added, removed|
|
7
|
+
puts "modified absolute path: #{modified}"
|
8
|
+
puts "added absolute path: #{added}"
|
9
|
+
puts "removed absolute path: #{removed}"
|
10
|
+
|
11
|
+
server.init_restart
|
12
|
+
end
|
13
|
+
@listener.start # not blocking
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_server_stop(server:)
|
17
|
+
# do my thing after the server stops
|
18
|
+
@listener.stop
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: istox_gruf
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: paranoia
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: graphlient
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: listen
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.0.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 3.0.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,10 +243,10 @@ files:
|
|
243
243
|
- lib/istox/helpers/bunny_boot.rb
|
244
244
|
- lib/istox/helpers/graphql_client.rb
|
245
245
|
- lib/istox/helpers/grpc_client.rb
|
246
|
+
- lib/istox/helpers/gruf_listener_hook.rb
|
246
247
|
- lib/istox/helpers/message_service.rb
|
247
248
|
- lib/istox/helpers/order_book.rb
|
248
249
|
- lib/istox/helpers/publisher.rb
|
249
|
-
- lib/istox/helpers/vault.rb
|
250
250
|
- lib/istox/interfaces/chainhub/transaction.rb
|
251
251
|
- lib/istox/migrations/create_blockchain_receipts.rb
|
252
252
|
- lib/istox/models/blockchain_receipt.rb
|
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
273
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.7.
|
274
|
+
rubygems_version: 2.7.9
|
275
275
|
signing_key:
|
276
276
|
specification_version: 4
|
277
277
|
summary: istox backend shared gem
|
data/lib/istox/helpers/vault.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'vault'
|
2
|
-
|
3
|
-
module Istox
|
4
|
-
module Vault
|
5
|
-
module TOTP
|
6
|
-
class << self
|
7
|
-
|
8
|
-
def create(sid, params={})
|
9
|
-
Rails.logger.debug { "Generate vault TOTP for key #{totp_key(sid).inspect}" }
|
10
|
-
|
11
|
-
write_data(totp_key(sid),
|
12
|
-
generate: true,
|
13
|
-
issuer: params[:host],
|
14
|
-
account_name: sid,
|
15
|
-
qr_size: 300)
|
16
|
-
end
|
17
|
-
|
18
|
-
def generate_code(sid)
|
19
|
-
Rails.logger.debug { "Generate 6-digit OTP code: key #{totp_code_key(sid)}" }
|
20
|
-
code = read_data(totp_code_key(sid)).data[:code]
|
21
|
-
code
|
22
|
-
end
|
23
|
-
|
24
|
-
def validate?(sid, code)
|
25
|
-
return false unless exist?(sid)
|
26
|
-
Rails.logger.debug { "Validate TOTP code: key #{totp_code_key(sid)}, code: #{code}" }
|
27
|
-
result = write_data(totp_code_key(sid), code: code).data[:valid]
|
28
|
-
|
29
|
-
unless result
|
30
|
-
code = read_data(totp_code_key(sid)).data[:code]
|
31
|
-
Rails.logger.debug { "Code is not valid, it should be #{code}" }
|
32
|
-
end
|
33
|
-
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def read_data(key)
|
40
|
-
::Vault.logical.read(key)
|
41
|
-
end
|
42
|
-
|
43
|
-
def write_data(key, params)
|
44
|
-
Rails.logger.debug { "in write data method" }
|
45
|
-
Rails.logger.debug { ::Vault }
|
46
|
-
::Vault.logical.write(key, params)
|
47
|
-
end
|
48
|
-
|
49
|
-
def totp_key(sid)
|
50
|
-
"totp/keys/#{sid}"
|
51
|
-
end
|
52
|
-
|
53
|
-
def totp_code_key(sid)
|
54
|
-
"totp/code/#{sid}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class << self
|
60
|
-
|
61
|
-
def logical
|
62
|
-
Rails.logger.debug { 'in logical method' }
|
63
|
-
::Vault.logical
|
64
|
-
end
|
65
|
-
|
66
|
-
def initialize(secret_key, file_location)
|
67
|
-
::Vault.configure do |config|
|
68
|
-
config.address = secret_key
|
69
|
-
|
70
|
-
if File.exist?(file_location)
|
71
|
-
token = File.read(file_location).strip
|
72
|
-
config.token = token
|
73
|
-
config.ssl_verify = false
|
74
|
-
config.timeout = 60
|
75
|
-
else
|
76
|
-
Rails.logger.info 'Vault token not found, OTP will not be able to use'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def get_otp(sid, host)
|
82
|
-
::Istox::Vault::TOTP.create(sid, host)
|
83
|
-
otp = Istox::Vault::TOTP.generate_code(sid)
|
84
|
-
|
85
|
-
return otp
|
86
|
-
end
|
87
|
-
|
88
|
-
def validate_otp(sid, otp)
|
89
|
-
return ::Istox::Vault::TOTP.validate?(sid, otp)
|
90
|
-
rescue => e
|
91
|
-
raise e
|
92
|
-
false
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|