shared-settings-ui 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +29 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +21 -0
- data/README.md +154 -0
- data/Rakefile +13 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/shared-settings-ui.rb +3 -0
- data/lib/shared-settings.rb +57 -0
- data/lib/shared_settings/configuration.rb +17 -0
- data/lib/shared_settings/instance.rb +26 -0
- data/lib/shared_settings/persistence/redis.rb +59 -0
- data/lib/shared_settings/serialized_setting.rb +81 -0
- data/lib/shared_settings/setting.rb +58 -0
- data/lib/shared_settings/ui.rb +23 -0
- data/lib/shared_settings/ui/action.rb +20 -0
- data/lib/shared_settings/ui/actions/asset.rb +15 -0
- data/lib/shared_settings/ui/actions/mount.rb +44 -0
- data/lib/shared_settings/ui/actions/setting.rb +57 -0
- data/lib/shared_settings/ui/assets/app.css +1 -0
- data/lib/shared_settings/ui/assets/app.js +2 -0
- data/lib/shared_settings/ui/assets/chunks.js +13 -0
- data/lib/shared_settings/ui/middleware.rb +45 -0
- data/lib/shared_settings/utilities/base16.rb +15 -0
- data/lib/shared_settings/utilities/encryption.rb +56 -0
- data/lib/shared_settings/version.rb +3 -0
- data/shared-settings-ui.gemspec +24 -0
- data/shared-settings.gemspec +21 -0
- metadata +107 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module SharedSettings
|
2
|
+
module Utilities
|
3
|
+
module Base16
|
4
|
+
def self.string_to_bytes(str)
|
5
|
+
str.scan(/../).inject('') do |binary, hex_char|
|
6
|
+
binary << hex_char.to_i(16).chr
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.bytes_to_string(bytestring)
|
11
|
+
bytestring.unpack1('H*').upcase
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module SharedSettings
|
5
|
+
module Utilities
|
6
|
+
class Encryption
|
7
|
+
INIT_VEC_SIZE = 16
|
8
|
+
AES_BLOCK_SIZE = 16
|
9
|
+
ENCRYPTION_KEY_SIZE = 32
|
10
|
+
|
11
|
+
ENCRYPTION_ALGORITHM = 'AES-256-CBC'.freeze
|
12
|
+
|
13
|
+
def self.generate_aes_key(size = ENCRYPTION_KEY_SIZE)
|
14
|
+
# .upcase is to match the Elixir implementation
|
15
|
+
SecureRandom.hex(size).upcase
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(key)
|
19
|
+
@key = key
|
20
|
+
end
|
21
|
+
|
22
|
+
def encrypt(clear_text)
|
23
|
+
init_vec = Encryption.generate_aes_key(INIT_VEC_SIZE)
|
24
|
+
cipher_instance = encryption_cipher(init_vec)
|
25
|
+
encrypted_data = cipher_instance.update(clear_text) + cipher_instance.final
|
26
|
+
|
27
|
+
[init_vec, Base16.bytes_to_string(encrypted_data)]
|
28
|
+
end
|
29
|
+
|
30
|
+
def decrypt(init_vec, cipher_text)
|
31
|
+
cipher_data = Base16.string_to_bytes(cipher_text)
|
32
|
+
cipher_instance = decryption_cipher(init_vec)
|
33
|
+
|
34
|
+
cipher_instance.update(cipher_data) + cipher_instance.final
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def encryption_cipher(init_vec)
|
40
|
+
build_cipher(OpenSSL::Cipher.new(ENCRYPTION_ALGORITHM).encrypt, init_vec)
|
41
|
+
end
|
42
|
+
|
43
|
+
def decryption_cipher(init_vec)
|
44
|
+
build_cipher(OpenSSL::Cipher.new(ENCRYPTION_ALGORITHM).decrypt, init_vec)
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_cipher(cipher, init_vec)
|
48
|
+
cipher.iv = Base16.string_to_bytes(init_vec)
|
49
|
+
cipher.key = Base16.string_to_bytes(@key)
|
50
|
+
cipher.padding = AES_BLOCK_SIZE
|
51
|
+
|
52
|
+
cipher
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'lib/shared_settings/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'shared-settings-ui'
|
5
|
+
spec.version = SharedSettings::VERSION
|
6
|
+
spec.authors = ['Kieran Eglin']
|
7
|
+
|
8
|
+
spec.summary = 'UI for shared-settings'
|
9
|
+
spec.description = 'A UI management interface for the shared-settings Gem'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
12
|
+
|
13
|
+
# Specify which files should be added to the gem when it is released.
|
14
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'rack', '>= 2.0', '< 3'
|
23
|
+
spec.add_dependency 'shared-settings', "~> #{SharedSettings::VERSION}"
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'lib/shared_settings/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'shared-settings'
|
5
|
+
spec.version = SharedSettings::VERSION
|
6
|
+
spec.authors = ['Kieran Eglin']
|
7
|
+
|
8
|
+
spec.summary = 'Easily manage runtime settings'
|
9
|
+
spec.description = 'Manage runtime and encrypt settings for your Ruby app with optional support for Elixir'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
12
|
+
|
13
|
+
# Specify which files should be added to the gem when it is released.
|
14
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shared-settings-ui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kieran Eglin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: shared-settings
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.1.0
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.0
|
47
|
+
description: A UI management interface for the shared-settings Gem
|
48
|
+
email:
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- ".github/workflows/ruby.yml"
|
54
|
+
- ".gitignore"
|
55
|
+
- ".rubocop.yml"
|
56
|
+
- Gemfile
|
57
|
+
- Gemfile.lock
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/console
|
62
|
+
- bin/setup
|
63
|
+
- lib/shared-settings-ui.rb
|
64
|
+
- lib/shared-settings.rb
|
65
|
+
- lib/shared_settings/configuration.rb
|
66
|
+
- lib/shared_settings/instance.rb
|
67
|
+
- lib/shared_settings/persistence/redis.rb
|
68
|
+
- lib/shared_settings/serialized_setting.rb
|
69
|
+
- lib/shared_settings/setting.rb
|
70
|
+
- lib/shared_settings/ui.rb
|
71
|
+
- lib/shared_settings/ui/action.rb
|
72
|
+
- lib/shared_settings/ui/actions/asset.rb
|
73
|
+
- lib/shared_settings/ui/actions/mount.rb
|
74
|
+
- lib/shared_settings/ui/actions/setting.rb
|
75
|
+
- lib/shared_settings/ui/assets/app.css
|
76
|
+
- lib/shared_settings/ui/assets/app.js
|
77
|
+
- lib/shared_settings/ui/assets/chunks.js
|
78
|
+
- lib/shared_settings/ui/middleware.rb
|
79
|
+
- lib/shared_settings/utilities/base16.rb
|
80
|
+
- lib/shared_settings/utilities/encryption.rb
|
81
|
+
- lib/shared_settings/version.rb
|
82
|
+
- shared-settings-ui.gemspec
|
83
|
+
- shared-settings.gemspec
|
84
|
+
homepage:
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.3.0
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.1.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: UI for shared-settings
|
107
|
+
test_files: []
|