razorrisk-cassini-utilities-secretserver 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5653cd591a0033c005a364ab5d99998e81cfffbf45cf20ea5bfade2bf818ce57
4
+ data.tar.gz: e86f0aa4762c4fd0a61fb2bd06169232004d29792f75f74c5eddf00b096c4201
5
+ SHA512:
6
+ metadata.gz: 585a28a65144fd1e1332559b70d14533e7ef0d2e4d54f40124a845cdf3b150a1d4f71142f6d7d74d3a52af46ac6a9f4f95c2dd81e03e25e643412edb8b82bcf1
7
+ data.tar.gz: 2b70508b09af1c534ba72b1ff195de47dc2f4607d1cd349fee323ef0ab6e3cce5d9a1f8c591d34eca89df0cee4433889ee1d3a33a8308b112b466b8eb9f00f00
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Change Log
2
+
3
+ ## [0.7.1] (2018-06-20)
4
+
5
+ **Implemented enhancements:**
6
+
7
+ none
8
+
9
+ **Fixed defects:**
10
+
11
+ none
12
+
13
+ **Dependencies and packaging:**
14
+
15
+ - separated into own project/repo/package [WEBAPI-138]
16
+
17
+ **Merged pull requests:**
18
+
19
+ none
20
+
21
+ ## END OF CHANGE LOG
22
+
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Cassini
2
+
3
+ Copyright (c) 2017-2018, Razor Risk Technologies Pty Ltd
4
+ All rights reserved.
5
+
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ T.B.C.
2
+
@@ -0,0 +1,295 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # ######################################################################## #
5
+ # File: tools/servers/secret-server/ws.rb
6
+ #
7
+ # Purpose: Main module/entry file for the Secret Server
8
+ #
9
+ # Author: Matthew Wilson
10
+ #
11
+ # Copyright (c) 2017-2018, Razor Risk Technologies Pty Ltd
12
+ # All rights reserved.
13
+ #
14
+ # ######################################################################## #
15
+
16
+
17
+ # ##########################################################################
18
+
19
+ # Utility: Secret Server (secret-server)
20
+ #
21
+ # Supported:
22
+ #
23
+ # - [GET] / {Unsecured}
24
+
25
+ # ##########################################################################
26
+ # requires
27
+
28
+ require 'razor_risk/cassini/diagnostics/zeroth_include'
29
+
30
+ require 'razor_risk/cassini/utilities/secret_server'
31
+
32
+ require 'razor_risk/cassini/applications/unsecured_microservice'
33
+ require 'razor_risk/cassini/cli'
34
+ require 'razor_risk/cassini/diagnostics/util_functions'
35
+ require 'razor_risk/cassini/extensions/libclimate'
36
+ require 'razor_risk/cassini/util/version_util'
37
+
38
+ require 'razor_risk/extensions/hash/dig'
39
+
40
+ require 'razor_risk/core/diagnostics/extensions/libclimate'
41
+ require 'razor_risk/core/diagnostics/logger'
42
+
43
+ require 'libclimate'
44
+ require 'pantheios'
45
+ require 'xqsr3/extensions/hash/deep_transform'
46
+
47
+ require 'xqsr3/extensions/kernel/integer'
48
+
49
+ require 'csv'
50
+ require 'json'
51
+ require 'logger'
52
+ require 'yaml'
53
+
54
+ # ##########################################################################
55
+ # includes
56
+
57
+ include ::RazorRisk::Cassini::Applications
58
+ include ::RazorRisk::Cassini::Util::VersionUtil
59
+
60
+ include ::RazorRisk::Cassini::Diagnostics
61
+ include ::RazorRisk::Core::Diagnostics::Logger
62
+
63
+ include ::Pantheios
64
+
65
+ # ##########################################################################
66
+ # constants
67
+
68
+ SERVER_ID = 'secret-server'
69
+
70
+ DEFAULT_ALGORITHM = 'sha256'
71
+
72
+ ACCEPT_TYPES = %w{ application/json application/xml text/csv text/plain text/tsv text/tab-separated-values text/xml }
73
+
74
+ PROGRAM_VERSION = ::RazorRisk::Cassini::Utilities::SecretServer::VERSION
75
+
76
+ module Constants
77
+
78
+ module Defaults
79
+
80
+ LOGGING_THRESHOLD = [ :informational, :debug ]
81
+ end # module Defaults
82
+ end # module Constants
83
+
84
+ # ##########################################################################
85
+ # compatibility checks
86
+
87
+ check_version_compatibility ::LibCLImate, '0.10'
88
+ check_version_compatibility ::Pantheios, '0.20'
89
+
90
+ # ##########################################################################
91
+ # static set-up
92
+
93
+ # ##########################################################################
94
+ # application
95
+
96
+ module SecretServer
97
+
98
+ include ::Pantheios
99
+ include ::RazorRisk::Core::Diagnostics::Logger
100
+
101
+ def included receiver
102
+
103
+ receiver.extend self
104
+ end
105
+
106
+ def make_CSV algorithm, secret
107
+
108
+ trace ParamNames[ :algorithm, :secret ], algorithm, secret
109
+
110
+ CSV.generate do |csv|
111
+
112
+ csv << [ algorithm, secret ]
113
+ end
114
+ end
115
+
116
+ def make_JSON algorithm, secret
117
+
118
+ trace ParamNames[ :algorithm, :secret ], algorithm, secret
119
+
120
+ r = { algorithm: algorithm, secret: secret }
121
+
122
+ r.to_json
123
+ end
124
+
125
+ def make_text algorithm, secret
126
+
127
+ trace ParamNames[ :algorithm, :secret ], algorithm, secret
128
+
129
+ "#{algorithm}|#{secret}"
130
+ end
131
+
132
+ def make_TSV algorithm, secret
133
+
134
+ trace ParamNames[ :algorithm, :secret ], algorithm, secret
135
+
136
+ "#{algorithm}\t#{secret}"
137
+ end
138
+
139
+ def make_XML algorithm, secret
140
+
141
+ trace ParamNames[ :algorithm, :secret ], algorithm, secret
142
+
143
+ #<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.we.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
144
+ <<END_OF_xml
145
+ <?xml version="1.0">
146
+ <secrets>
147
+ <secret algorithm="#{algorithm}" secret="#{secret}" />
148
+ </secrets>
149
+ END_OF_xml
150
+ end
151
+ end
152
+
153
+ class SecretServerApp < UnsecuredMicroservice
154
+
155
+ include SecretServer
156
+
157
+ def self.on_init_service options
158
+
159
+ raise ArgumentError, 'missing keyword: secrets' unless options.has_key? :secrets
160
+
161
+ secrets = options[:secrets]
162
+
163
+ settings.set :secrets, (secrets || {}).deep_transform { |k, v| [ k.to_s.downcase, v ] }
164
+ end
165
+
166
+ get '/' do
167
+
168
+ trace
169
+
170
+ category = params[:category] || 'all'
171
+ algorithm = params[:algorithm] || DEFAULT_ALGORITHM
172
+
173
+ category = category.downcase
174
+ algorithm = algorithm.downcase
175
+
176
+ log :info, 'obtaining secret for category \'', category, '\' and algorithm \'', algorithm, '\''
177
+
178
+ secret = nil
179
+ secret ||= settings.secrets.dig(category, algorithm) if 'all' != category
180
+ secret ||= settings.secrets.dig('all', algorithm)
181
+
182
+ halt *[ 404, {}, "no such algorithm '#{algorithm}' for category '#{category}'" ] unless secret
183
+
184
+ ACCEPT_TYPES.each do |accept_type|
185
+
186
+ if request.accept? accept_type
187
+
188
+ content_type accept_type
189
+
190
+ case accept_type
191
+ when 'application/json'
192
+
193
+ r = make_JSON algorithm, secret
194
+ when 'text/plain'
195
+
196
+ r = make_text algorithm, secret
197
+ when 'application/xml', 'text/xml'
198
+
199
+ r = make_XML algorithm, secret
200
+ when 'text/csv'
201
+
202
+ r = make_CSV algorithm, secret
203
+ when 'text/tsv', 'text/tab-separated-values'
204
+
205
+ r = make_TSV algorithm, secret
206
+ else
207
+
208
+ log :violation, 'unrecognised accept type \'', accept_type, '\''
209
+
210
+ halt *[ 500, {}, 'internal server failure' ]
211
+ end
212
+
213
+ return r
214
+ end
215
+ end
216
+
217
+ halt *[ 406, {}, "supports only the Accept types #{ACCEPT_TYPES.map { |t| %Q<'#{t}'> }.join(', ')}" ]
218
+ end
219
+ end
220
+
221
+ TheApp = SecretServerApp
222
+
223
+ # ##########################################################################
224
+ # command-line parsing
225
+
226
+ options = {}
227
+
228
+ climate = LibCLImate::Climate.new do |cl|
229
+
230
+ cl.option_web_server options
231
+
232
+ cl.option_host options
233
+ cl.option_port options
234
+
235
+ cl.option_log_threshold options, default_level: Constants::Defaults::LOGGING_THRESHOLD
236
+
237
+ cl.usage_values = '<secret-config-path>'
238
+
239
+ cl.info_lines = [
240
+
241
+ 'Secret server',
242
+ ::RazorRisk::Cassini::CLI.Copyright(2017),
243
+ :version,
244
+ ]
245
+ end
246
+
247
+ log :debug0, 'parsing command line ...'
248
+
249
+ r = climate.run ARGV
250
+
251
+ ::Pantheios::Core.program_name = options[:program_name] if options[:program_name]
252
+
253
+ program_name = ::Pantheios::Core.program_name
254
+ log_directory = options[:log_directory] || './logs'
255
+ log_threshold = options[:log_threshold] || :notice
256
+
257
+ setup_diagnostic_logging program_name, log_directory, log_threshold
258
+
259
+
260
+ # amass the arguments that are required
261
+
262
+ secrets_config_path = r.values[0] or climate.abort 'no secret-config-path specified'
263
+
264
+ options[:host] ||= nil
265
+
266
+ secrets_config = YAML.load_file secrets_config_path
267
+
268
+ secrets = secrets_config['secrets']
269
+
270
+ secrets.has_key?('all') or climate.abort 'secrets must contain "all" key'
271
+
272
+ # ##########################################################################
273
+ # main
274
+
275
+ log :debug0, 'options: ', options
276
+
277
+ log :informational, 'initialising application ...'
278
+
279
+ begin
280
+
281
+ TheApp.init_service **options, secrets: secrets
282
+ rescue => x
283
+
284
+ log :alert, "exception(#{x.class}): #{x.message}"
285
+
286
+ climate.abort x.message
287
+ end
288
+
289
+ log :notice, "starting secret server"
290
+
291
+ TheApp.run!
292
+
293
+ # ############################## end of file ############################# #
294
+
295
+
@@ -0,0 +1,52 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ # File: razor_risk/cassini/utilities/secret_server/version.rb
5
+ #
6
+ # Purpose: Version for RazorRisk.Cassini.Utilities.SecretServer library
7
+ #
8
+ # Created: 8th January 2019
9
+ # Updated: 11th January 2019
10
+ #
11
+ # Copyright (c) 2018, Razor Risk Technologies Pty Ltd
12
+ # All rights reserved.
13
+ #
14
+ # ######################################################################## #
15
+
16
+
17
+ =begin
18
+ =end
19
+
20
+ module RazorRisk
21
+ module Cassini
22
+ module Utilities
23
+
24
+ module SecretServer
25
+
26
+ # Current version of the RazorRisk.Cassini.CassiD library
27
+ VERSION = '0.7.9'
28
+
29
+ private
30
+ VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
31
+ public
32
+ # Major version of the RazorRisk.Cassini.CassiD library
33
+ VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
34
+ # Minor version of the RazorRisk.Cassini.CassiD library
35
+ VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
36
+ # Patch version of the RazorRisk.Cassini.CassiD library
37
+ VERSION_PATCH = VERSION_PARTS_[2] # :nodoc:
38
+ # Commit version of the RazorRisk.Cassini.CassiD library
39
+ VERSION_COMMIT = VERSION_PARTS_[3] || 0 # :nodoc:
40
+
41
+
42
+ # The description of the framework
43
+ DESCRIPTION = "Razor Risk's Cassini Web-framework's Secret Server utility"
44
+
45
+ end # module SecretServer
46
+ end # module Utilities
47
+ end # module Cassini
48
+ end # module RazorRisk
49
+
50
+ # ############################## end of file ############################# #
51
+
52
+
@@ -0,0 +1,2 @@
1
+
2
+ require 'razor_risk/cassini/utilities/secret_server/version'
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: razorrisk-cassini-utilities-secretserver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.9
5
+ platform: ruby
6
+ authors:
7
+ - Razor Risk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: razorrisk-cassini-common
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.21'
27
+ - !ruby/object:Gem::Dependency
28
+ name: razorrisk-core-diagnostics-extensions
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clasp-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.14'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.8.3
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.8'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.8.3
75
+ - !ruby/object:Gem::Dependency
76
+ name: libclimate-ruby
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.10'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.10'
89
+ - !ruby/object:Gem::Dependency
90
+ name: pantheios-ruby
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.20.2
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.20.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: sinatra
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.4'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.4.8
113
+ type: :runtime
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.4'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 1.4.8
123
+ - !ruby/object:Gem::Dependency
124
+ name: xqsr3
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.30'
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '0.30'
137
+ description: Razor Risk's Cassini Web-framework's Secret Server utility
138
+ email: operations@razor-risk.com
139
+ executables:
140
+ - razorrisk-microservice-secretserver
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - CHANGELOG.md
145
+ - LICENSE
146
+ - README.md
147
+ - bin/razorrisk-microservice-secretserver
148
+ - lib/razor_risk/cassini/utilities/secret_server.rb
149
+ - lib/razor_risk/cassini/utilities/secret_server/version.rb
150
+ homepage: https://razor-risk.com/
151
+ licenses:
152
+ - Nonstandard
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: '2.0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.2.3
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Razor Risk Cassini Secret Server utility
173
+ test_files: []