waylon-core 0.1.5 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -2
- data/lib/waylon/base_component.rb +1 -1
- data/lib/waylon/config.rb +4 -5
- data/lib/waylon/core.rb +2 -0
- data/lib/waylon/rspec/test_server.rb +1 -1
- data/lib/waylon/rspec.rb +1 -1
- data/lib/waylon/storage.rb +46 -0
- data/lib/waylon/version.rb +1 -1
- data/scripts/release.sh +2 -0
- data/scripts/test.sh +2 -0
- data/waylon-core.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 628f00817729895a327ec3adff832ba15fdb071da3762a061eb637b0492b2953
|
4
|
+
data.tar.gz: 17276d8b5acbdaf2b5c90766329d53ec8fe42d0afae64f7aa062ad0a4cb1a381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6724d7e8ee142b43534ca17fd53d729272d83ab0f6e5f3ef0cf1b07ac63a552bc8393a167b1d6f324cf809fd27bb88f6379375929f130481a16b1ef69f24068e
|
7
|
+
data.tar.gz: 800fa36240abe3b85afc58951efa01c519fa6802d74d9fe92a67eb5719e3d25dfc2348f6d38dc347be7ccf9d6c7c1a6e4f4ca92d3117c04775a67ed151295a3e
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waylon-core (0.1.
|
4
|
+
waylon-core (0.1.9)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
faraday (~> 1.8)
|
7
7
|
i18n (~> 1.8)
|
8
8
|
json (~> 2.6)
|
9
9
|
moneta (~> 1.4)
|
10
10
|
puma (~> 5.5)
|
11
|
+
rbnacl (~> 7.1)
|
11
12
|
resque (~> 2.2)
|
12
13
|
|
13
14
|
GEM
|
@@ -42,13 +43,14 @@ GEM
|
|
42
43
|
faraday-patron (1.0.0)
|
43
44
|
faraday-rack (1.0.0)
|
44
45
|
faraday-retry (1.0.3)
|
46
|
+
ffi (1.15.5)
|
45
47
|
i18n (1.10.0)
|
46
48
|
concurrent-ruby (~> 1.0)
|
47
49
|
json (2.6.2)
|
48
50
|
moneta (1.5.1)
|
49
51
|
mono_logger (1.1.1)
|
50
52
|
multi_json (1.15.0)
|
51
|
-
multipart-post (2.2.
|
53
|
+
multipart-post (2.2.3)
|
52
54
|
mustermann (1.1.1)
|
53
55
|
ruby2_keywords (~> 0.0.1)
|
54
56
|
nio4r (2.5.8)
|
@@ -63,6 +65,8 @@ GEM
|
|
63
65
|
rack
|
64
66
|
rainbow (3.1.1)
|
65
67
|
rake (13.0.6)
|
68
|
+
rbnacl (7.1.1)
|
69
|
+
ffi
|
66
70
|
redis (4.6.0)
|
67
71
|
redis-namespace (1.8.2)
|
68
72
|
redis (>= 3.0.4)
|
data/lib/waylon/config.rb
CHANGED
@@ -32,11 +32,10 @@ module Waylon
|
|
32
32
|
|
33
33
|
# Load in the config from env variables
|
34
34
|
# @return [Boolean] Was the configuration loaded?
|
35
|
-
def load_env
|
35
|
+
def load_env
|
36
36
|
@schema ||= {}
|
37
37
|
self["global.log.level"] = ENV.fetch("LOG_LEVEL", "info")
|
38
|
-
self["global.redis
|
39
|
-
self["global.redis.port"] = ENV.fetch("REDIS_PORT", "6379")
|
38
|
+
self["global.redis"] = ENV.fetch("REDIS", "localhost:6379")
|
40
39
|
self["global.admins"] = ENV.fetch("GLOBAL_ADMINS", "")
|
41
40
|
ENV.keys.grep(/CONF_/).each do |env_key|
|
42
41
|
conf_key = env_key.downcase.split("_")[1..].join(".")
|
@@ -49,13 +48,13 @@ module Waylon
|
|
49
48
|
# Provides the redis host used for most of Waylon's brain
|
50
49
|
# @return [String] The redis host
|
51
50
|
def redis_host
|
52
|
-
self["global.redis.
|
51
|
+
self["global.redis"].split(":").first
|
53
52
|
end
|
54
53
|
|
55
54
|
# Provides the redis port used for most of Waylon's brain
|
56
55
|
# @return [String] The redis host
|
57
56
|
def redis_port
|
58
|
-
self["global.redis.
|
57
|
+
self["global.redis"].split(":").last
|
59
58
|
end
|
60
59
|
|
61
60
|
# Clear the configuration
|
data/lib/waylon/core.rb
CHANGED
@@ -21,6 +21,7 @@ require "faraday"
|
|
21
21
|
require "i18n"
|
22
22
|
require "json"
|
23
23
|
require "moneta"
|
24
|
+
require "rbnacl"
|
24
25
|
require "resque"
|
25
26
|
require "sinatra"
|
26
27
|
|
@@ -32,6 +33,7 @@ require "waylon/exceptions/not_implemented_error"
|
|
32
33
|
require "waylon/exceptions/validation_error"
|
33
34
|
require "waylon/group"
|
34
35
|
require "waylon/logger"
|
36
|
+
require "waylon/storage"
|
35
37
|
require "waylon/base_component"
|
36
38
|
require "waylon/condition"
|
37
39
|
require "waylon/message"
|
@@ -20,7 +20,7 @@ config = Waylon::Config.instance
|
|
20
20
|
config.load_env
|
21
21
|
|
22
22
|
Waylon::Cache = Moneta.new(:Cookie)
|
23
|
-
Waylon::Storage
|
23
|
+
p Waylon::Storage
|
24
24
|
Waylon::Logger.log("Found Global Admins: #{config.admins}")
|
25
25
|
|
26
26
|
Waylon::RSpec::TestUser.find_or_create(
|
data/lib/waylon/rspec.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Waylon::Cache = Moneta.new(
|
4
|
+
:Redis,
|
5
|
+
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
|
6
|
+
)
|
7
|
+
|
8
|
+
module Waylon
|
9
|
+
# Used for working with the Moneta store
|
10
|
+
module Storage
|
11
|
+
Store = Moneta.new(
|
12
|
+
:Redis,
|
13
|
+
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
|
14
|
+
)
|
15
|
+
|
16
|
+
def self.cipher
|
17
|
+
key_bytes = RbNaCl::Hash.sha256(ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U"))[0..31]
|
18
|
+
RbNaCl::SimpleBox.from_secret_key(key_bytes)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.clear
|
22
|
+
Store.clear
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.key?(name)
|
26
|
+
Store.key?(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.load(key)
|
30
|
+
this_cipher = cipher
|
31
|
+
raw = Store.load(key)
|
32
|
+
return nil unless raw
|
33
|
+
|
34
|
+
decoded = Base64.decode64(raw)
|
35
|
+
plain = this_cipher.decrypt(decoded)
|
36
|
+
JSON.parse(plain)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.store(key, value)
|
40
|
+
this_cipher = cipher
|
41
|
+
encrypted = this_cipher.encrypt(value.to_json)
|
42
|
+
encoded = Base64.encode64(encrypted)
|
43
|
+
Store.store(key, encoded)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/waylon/version.rb
CHANGED
data/scripts/release.sh
CHANGED
data/scripts/test.sh
CHANGED
data/waylon-core.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency "json", "~> 2.6"
|
34
34
|
spec.add_dependency "moneta", "~> 1.4"
|
35
35
|
spec.add_dependency "puma", "~> 5.5"
|
36
|
+
spec.add_dependency "rbnacl", "~> 7.1"
|
36
37
|
spec.add_dependency "resque", "~> 2.2"
|
37
38
|
|
38
39
|
spec.add_development_dependency "bundler", "~> 2.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waylon-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rbnacl
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '7.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '7.1'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: resque
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,6 +297,7 @@ files:
|
|
283
297
|
- lib/waylon/skills/fun.rb
|
284
298
|
- lib/waylon/skills/groups.rb
|
285
299
|
- lib/waylon/skills/help.rb
|
300
|
+
- lib/waylon/storage.rb
|
286
301
|
- lib/waylon/user.rb
|
287
302
|
- lib/waylon/version.rb
|
288
303
|
- lib/waylon/webhook.rb
|