web47core 1.0.5 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app/controllers/concerns/core_delayed_jobs_controller.rb +1 -1
- data/lib/app/jobs/cron/server.rb +1 -1
- data/lib/app/jobs/cron/trim_collection.rb +8 -1
- data/lib/app/models/concerns/cipher_able.rb +51 -0
- data/lib/app/models/concerns/encrypted_password.rb +41 -0
- data/lib/web47core.rb +2 -0
- data/lib/web47core/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47a4d6b158639c596b5ed01bc73a7f163d19e8ccd9bb7d51089b640368ce9e5b
|
4
|
+
data.tar.gz: 9203632b762294331dc976f61cc99eab95979d1ec58a95405286ba98ae6c58a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b150960174a0f848103fcbec5be7847b4115abce5ba1ee00351bb028fe1bd16bd9f84b5a58b463b0b7eb71002c6e5917028208ca09cfeedf4631adcea09ae3
|
7
|
+
data.tar.gz: e67b0d44151b9e0a8aea5e55e7427ca0b527ea9f9c05e70abb65ef011ada7db91e58b11ae3fa4ba9bc88ba5bd9632d7cc5a667bb0d7771d7a5b785b5742e72bb
|
@@ -10,7 +10,7 @@ module CoreDelayedJobsController
|
|
10
10
|
#
|
11
11
|
def index
|
12
12
|
authorize! :read, Delayed::Backend::Mongoid::Job
|
13
|
-
@delayed_jobs = Delayed::Backend::Mongoid::Job.asc(%i[priority run_at]).limit(100)
|
13
|
+
@delayed_jobs = Delayed::Backend::Mongoid::Job.asc(%i[locked_by priority run_at]).limit(100)
|
14
14
|
end
|
15
15
|
|
16
16
|
def show
|
data/lib/app/jobs/cron/server.rb
CHANGED
@@ -185,7 +185,7 @@ module Cron
|
|
185
185
|
# Returns the AutoScalingGroup associated with the account
|
186
186
|
#
|
187
187
|
def auto_scaling_group
|
188
|
-
filter = { auto_scaling_group_names: [sys_config.
|
188
|
+
filter = { auto_scaling_group_names: [sys_config.aws_auto_scaling_group_name] }
|
189
189
|
@auto_scaling_group ||= client.describe_auto_scaling_groups(filter).auto_scaling_groups.first
|
190
190
|
end
|
191
191
|
|
@@ -31,12 +31,19 @@ module Cron
|
|
31
31
|
# Test if this should be archived
|
32
32
|
#
|
33
33
|
def archive?(item)
|
34
|
-
item.
|
34
|
+
item.send(comparison_field) < allowed_time_for_item(item)
|
35
35
|
rescue StandardError => error
|
36
36
|
App47Logger.log_warn "Unable to archive item #{item.inspect}", error
|
37
37
|
false
|
38
38
|
end
|
39
39
|
|
40
|
+
#
|
41
|
+
# Return which field to use for comparison when trimming objects
|
42
|
+
#
|
43
|
+
def comparison_field
|
44
|
+
:updated_at
|
45
|
+
end
|
46
|
+
|
40
47
|
#
|
41
48
|
# Try to get a TTL from System configuration, otherwise return the default
|
42
49
|
#
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# A mixin to help with encrypting data in a secure way
|
3
|
+
#
|
4
|
+
module CipherAble
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
# Add to the model
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
#
|
10
|
+
# Fields
|
11
|
+
#
|
12
|
+
field :secret_key, type: BSON::Binary
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Encrypt the given text
|
18
|
+
#
|
19
|
+
def encrypt(text)
|
20
|
+
cipher.encrypt_and_sign(text)
|
21
|
+
rescue StandardError => error
|
22
|
+
App47Logger.log_error("Unable to encrypt text for #{inspect}", error)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Decrypt the given text
|
28
|
+
#
|
29
|
+
def decrypt(text)
|
30
|
+
cipher.decrypt_and_verify(text)
|
31
|
+
rescue StandardError => error
|
32
|
+
App47Logger.log_warn("Unable to decrypt text for #{inspect}", error)
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Get the cipher directly
|
38
|
+
#
|
39
|
+
def cipher
|
40
|
+
generate_key if secret_key.blank?
|
41
|
+
ActiveSupport::MessageEncryptor.new(secret_key.data)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def generate_key
|
47
|
+
len = ActiveSupport::MessageEncryptor.key_len
|
48
|
+
salt = SecureRandom.random_bytes(len)
|
49
|
+
set secret_key: BSON::Binary.new(ActiveSupport::KeyGenerator.new(id.to_s).generate_key(salt, len))
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Hold onto a secure password supporting both storage (setting) and retrieval ()getting) the password.
|
3
|
+
#
|
4
|
+
# The security will lie in the key that is offered by the object. By default it will be the ID of the object
|
5
|
+
# however it should really use be combined with some other known value like account.id or something
|
6
|
+
#
|
7
|
+
module EncryptedPassword
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
#
|
10
|
+
# Base class extension
|
11
|
+
#
|
12
|
+
def self.included(base)
|
13
|
+
base.class_eval do
|
14
|
+
include CipherAble
|
15
|
+
#
|
16
|
+
# Fields
|
17
|
+
#
|
18
|
+
field :encrypted_password, type: String
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Retrieve the password
|
24
|
+
#
|
25
|
+
def password
|
26
|
+
encrypted_password.present? ? cipher.decrypt_and_verify(encrypted_password) : ''
|
27
|
+
rescue StandardError => error
|
28
|
+
App47Logger.log_warn("Unable to retrieve password for #{inspect}", error)
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Set the password
|
34
|
+
#
|
35
|
+
def password=(pass)
|
36
|
+
set encrypted_password: cipher.encrypt_and_sign(pass)
|
37
|
+
rescue StandardError => error
|
38
|
+
App47Logger.log_error("Unable to store password for #{inspect}", error)
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
data/lib/web47core.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'web47core/config'
|
2
2
|
require 'app/models/concerns/app47_logger'
|
3
|
+
require 'app/models/concerns/cipher_able'
|
3
4
|
require 'app/models/concerns/cdn_url'
|
4
5
|
require 'app/models/concerns/email_able'
|
5
6
|
require 'app/models/concerns/search_able'
|
@@ -10,6 +11,7 @@ require 'app/models/concerns/switchboard_able'
|
|
10
11
|
require 'app/models/concerns/core_system_configuration'
|
11
12
|
require 'app/models/concerns/core_account'
|
12
13
|
require 'app/models/concerns/secure_fields'
|
14
|
+
require 'app/models/concerns/encrypted_password'
|
13
15
|
require 'app/models/delayed_job'
|
14
16
|
require 'app/models/redis_configuration'
|
15
17
|
require 'app/models/notification'
|
data/lib/web47core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web47core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schroeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -633,9 +633,11 @@ files:
|
|
633
633
|
- lib/app/models/audit_log.rb
|
634
634
|
- lib/app/models/concerns/app47_logger.rb
|
635
635
|
- lib/app/models/concerns/cdn_url.rb
|
636
|
+
- lib/app/models/concerns/cipher_able.rb
|
636
637
|
- lib/app/models/concerns/core_account.rb
|
637
638
|
- lib/app/models/concerns/core_system_configuration.rb
|
638
639
|
- lib/app/models/concerns/email_able.rb
|
640
|
+
- lib/app/models/concerns/encrypted_password.rb
|
639
641
|
- lib/app/models/concerns/role_able.rb
|
640
642
|
- lib/app/models/concerns/search_able.rb
|
641
643
|
- lib/app/models/concerns/secure_fields.rb
|