web47core 1.0.1 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 243a14b5c257b4418b1f3fb06fe504626da2e8ff2582221315113ee18e3435ca
4
- data.tar.gz: e23e24932be761b357ca2d17640ce4b11784e29e28a76836ead909eb0fd42e64
3
+ metadata.gz: 7f9275f3f097ae096f3de33a7b387e107d1a0e08fa01ae37d369a22e814db22d
4
+ data.tar.gz: 3a2080a56ef021eccb2e398ec51f9c1bd474450924c00e1b8a0f82ad6fd13473
5
5
  SHA512:
6
- metadata.gz: 5ada9afb71746a6716c8ea073448a1519a29c723b45740e3e02da716f0afef7ce82320c9c77f29c34de454f10036241827ec6008b432a420cc5c7ceb7b03ee2f
7
- data.tar.gz: d0f529149d16381c6d236651fad80c23c999981e150cc722a73112f455369ca17242a5fdeef81c8d732d0cd6a863d2f9505ca578ff43ae507b93802cf5884170
6
+ metadata.gz: 9d7013d8e16ae68be5adfe2f8b38a9536d8acb4fda7b7907f0afe1d41c0fcda941a86bcef4c021d079211907c6a9081cdc22a5744eb6f7042fc94a9169edb0d4
7
+ data.tar.gz: 36bc38a23ee63292623e95d32035d9b7962ff1070c71f91d424ea62a65393f704bdee0544c9fad97ce0f0f1f2495e700559c5b61f9a9a81401d4e02adb3b19e5
@@ -0,0 +1,34 @@
1
+ #
2
+ # Enable copy capability to the machines copy/paste buffer
3
+ #
4
+ $(document).ready ->
5
+ if clipboardEnabled()
6
+ $('a.copy').on 'click', (e) ->
7
+ node = e.target
8
+ textField = document.createElement('textarea')
9
+ node.parentNode.insertBefore(textField, node)
10
+ try
11
+ textField.innerText = $(this).data('clipboard-text')
12
+ textField.select()
13
+ textField.focus()
14
+ if document.execCommand('copy')
15
+ M.toast({html: 'Copied!'}, 3000);
16
+ else
17
+ M.toast({html: 'Unable to copy text'}, 3000);
18
+ catch error
19
+ M.toast({html: 'Unable to copy text'}, 3000);
20
+ finally
21
+ textField.parentNode.removeChild(textField)
22
+
23
+ else
24
+ $('.copy').hide()
25
+
26
+ #
27
+ # Test that we can issue the execCommand for copy and that it returns
28
+ #
29
+ clipboardEnabled = ->
30
+ try
31
+ document.execCommand('copy')
32
+ true
33
+ catch error
34
+ false
@@ -0,0 +1,13 @@
1
+ .clipboard {
2
+ margin: 0 0 0 2px;
3
+ padding: 0;
4
+ span {
5
+ font-size: 1rem;
6
+ }
7
+ a.copy {
8
+ i.material-icons {
9
+ i.material-icons;
10
+ font-size: 1rem;
11
+ }
12
+ }
13
+ }
@@ -17,7 +17,7 @@ module CoreLinkHelper
17
17
  # Setup the text as copy text
18
18
  #
19
19
  def copy_tag(copy_text, options = {})
20
- content_tag(:p, class: 'stack-tight') do
20
+ content_tag(:div, class: 'clipboard') do
21
21
  concat(content_tag(:span) { copy_text })
22
22
  concat(copy_text_tag(copy_text, options))
23
23
  concat(download_tag(options[:download_url], options)) if options[:download_url].present?
@@ -38,7 +38,7 @@ module Cron
38
38
  def job_names
39
39
  @job_names ||= all_jobs.collect do |job|
40
40
  job_name = job.to_s
41
- next if FRAMEWORK_CLASSES.include?(job_name) || job_name.end_with?('Test') || job_name.start_with?('Base')
41
+ next if FRAMEWORK_CLASSES.include?(job_name) || job_name.end_with?('_test') || job_name.start_with?('base_')
42
42
 
43
43
  job_name.underscore
44
44
  end.compact
@@ -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
@@ -10,8 +10,21 @@ module SecureFields
10
10
  # Remove updates for secure fields
11
11
  #
12
12
  def update(params)
13
- secure_fields.each { |field| params.delete(field) if params[field].blank? }
14
- super(params)
13
+ super(filter_secure_fields(params))
14
+ end
15
+
16
+ #
17
+ # Remove updates for secure fields
18
+ #
19
+ def update!(params)
20
+ super(filter_secure_fields(params))
21
+ end
22
+
23
+ #
24
+ # Remove updates for secure fields
25
+ #
26
+ def assign_attributes(params)
27
+ super(filter_secure_fields(params))
15
28
  end
16
29
 
17
30
  #
@@ -20,4 +33,9 @@ module SecureFields
20
33
  def secure_fields
21
34
  []
22
35
  end
36
+
37
+ def filter_secure_fields(params)
38
+ secure_fields.each { |field| params.delete(field) if params[field].blank? }
39
+ params
40
+ end
23
41
  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 SecurePassword
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
+ 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=(password)
36
+ set encrypted_password: cipher.encrypt_and_sign(password)
37
+ rescue StandardError => error
38
+ App47Logger.log_error("Unable to store password for #{inspect}", error)
39
+ nil
40
+ end
41
+ end
@@ -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'
@@ -9,6 +10,8 @@ require 'app/models/concerns/standard_model'
9
10
  require 'app/models/concerns/switchboard_able'
10
11
  require 'app/models/concerns/core_system_configuration'
11
12
  require 'app/models/concerns/core_account'
13
+ require 'app/models/concerns/secure_fields'
14
+ require 'app/models/concerns/secure_password'
12
15
  require 'app/models/delayed_job'
13
16
  require 'app/models/redis_configuration'
14
17
  require 'app/models/notification'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.6'
5
5
  end
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.1
4
+ version: 1.0.6
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-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -570,7 +570,9 @@ files:
570
570
  - LICENSE
571
571
  - README.md
572
572
  - app/assets/images/1x1.png
573
+ - app/assets/javascript/clipboard.coffee
573
574
  - app/assets/javascript/flash.coffee
575
+ - app/assets/stylesheets/clipboard.scss
574
576
  - app/controllers/exceptions_controller.rb
575
577
  - app/controllers/notifications_controller.rb
576
578
  - app/controllers/status_controller.rb
@@ -631,12 +633,14 @@ files:
631
633
  - lib/app/models/audit_log.rb
632
634
  - lib/app/models/concerns/app47_logger.rb
633
635
  - lib/app/models/concerns/cdn_url.rb
636
+ - lib/app/models/concerns/cipher_able.rb
634
637
  - lib/app/models/concerns/core_account.rb
635
638
  - lib/app/models/concerns/core_system_configuration.rb
636
639
  - lib/app/models/concerns/email_able.rb
637
640
  - lib/app/models/concerns/role_able.rb
638
641
  - lib/app/models/concerns/search_able.rb
639
642
  - lib/app/models/concerns/secure_fields.rb
643
+ - lib/app/models/concerns/secure_password.rb
640
644
  - lib/app/models/concerns/standard_model.rb
641
645
  - lib/app/models/concerns/switchboard_able.rb
642
646
  - lib/app/models/concerns/time_zone_able.rb