encrypted_attribute 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5c9205ab562bd982a7df0c92407bf6170f2481df1576aeadc8d900ce8a44fad3
4
+ data.tar.gz: 87a7f96829e4b45b472d6e09d58d1ee886fe7edd7a3b573a3c83c65fc754144a
5
+ SHA512:
6
+ metadata.gz: 13eafb104aacce3f152e83ad9e1e88935f929c615dc55107f12fbdc9517ca373dcec6046c12c0b5a6c2408aa6b90323f80592f2e54f838b015da3dd219ca9007
7
+ data.tar.gz: 2f16076fe08d7ee54928aa1741984c5540bf9d073b79970171f3710d5e3960d92e896541989aa6206c5edf278c1dba3810668326ed0c91a480fa0c860645bcc4
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ vendor/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in encrypted_attribute.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ encrypted_attribute (0.1.0)
5
+ activesupport
6
+ rails
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.0.3.4)
12
+ actionpack (= 6.0.3.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.0.3.4)
16
+ actionpack (= 6.0.3.4)
17
+ activejob (= 6.0.3.4)
18
+ activerecord (= 6.0.3.4)
19
+ activestorage (= 6.0.3.4)
20
+ activesupport (= 6.0.3.4)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.3.4)
23
+ actionpack (= 6.0.3.4)
24
+ actionview (= 6.0.3.4)
25
+ activejob (= 6.0.3.4)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.3.4)
29
+ actionview (= 6.0.3.4)
30
+ activesupport (= 6.0.3.4)
31
+ rack (~> 2.0, >= 2.0.8)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.3.4)
36
+ actionpack (= 6.0.3.4)
37
+ activerecord (= 6.0.3.4)
38
+ activestorage (= 6.0.3.4)
39
+ activesupport (= 6.0.3.4)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.3.4)
42
+ activesupport (= 6.0.3.4)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.3.4)
48
+ activesupport (= 6.0.3.4)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.0.3.4)
51
+ activesupport (= 6.0.3.4)
52
+ activerecord (6.0.3.4)
53
+ activemodel (= 6.0.3.4)
54
+ activesupport (= 6.0.3.4)
55
+ activestorage (6.0.3.4)
56
+ actionpack (= 6.0.3.4)
57
+ activejob (= 6.0.3.4)
58
+ activerecord (= 6.0.3.4)
59
+ marcel (~> 0.3.1)
60
+ activesupport (6.0.3.4)
61
+ concurrent-ruby (~> 1.0, >= 1.0.2)
62
+ i18n (>= 0.7, < 2)
63
+ minitest (~> 5.1)
64
+ tzinfo (~> 1.1)
65
+ zeitwerk (~> 2.2, >= 2.2.2)
66
+ builder (3.2.4)
67
+ concurrent-ruby (1.1.7)
68
+ crass (1.0.6)
69
+ erubi (1.9.0)
70
+ globalid (0.4.2)
71
+ activesupport (>= 4.2.0)
72
+ i18n (1.8.5)
73
+ concurrent-ruby (~> 1.0)
74
+ loofah (2.7.0)
75
+ crass (~> 1.0.2)
76
+ nokogiri (>= 1.5.9)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
81
+ method_source (1.0.0)
82
+ mimemagic (0.3.5)
83
+ mini_mime (1.0.2)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.14.2)
86
+ nio4r (2.5.4)
87
+ nokogiri (1.10.10)
88
+ mini_portile2 (~> 2.4.0)
89
+ rack (2.2.3)
90
+ rack-test (1.1.0)
91
+ rack (>= 1.0, < 3)
92
+ rails (6.0.3.4)
93
+ actioncable (= 6.0.3.4)
94
+ actionmailbox (= 6.0.3.4)
95
+ actionmailer (= 6.0.3.4)
96
+ actionpack (= 6.0.3.4)
97
+ actiontext (= 6.0.3.4)
98
+ actionview (= 6.0.3.4)
99
+ activejob (= 6.0.3.4)
100
+ activemodel (= 6.0.3.4)
101
+ activerecord (= 6.0.3.4)
102
+ activestorage (= 6.0.3.4)
103
+ activesupport (= 6.0.3.4)
104
+ bundler (>= 1.3.0)
105
+ railties (= 6.0.3.4)
106
+ sprockets-rails (>= 2.0.0)
107
+ rails-dom-testing (2.0.3)
108
+ activesupport (>= 4.2.0)
109
+ nokogiri (>= 1.6)
110
+ rails-html-sanitizer (1.3.0)
111
+ loofah (~> 2.3)
112
+ railties (6.0.3.4)
113
+ actionpack (= 6.0.3.4)
114
+ activesupport (= 6.0.3.4)
115
+ method_source
116
+ rake (>= 0.8.7)
117
+ thor (>= 0.20.3, < 2.0)
118
+ rake (12.3.3)
119
+ sprockets (4.0.2)
120
+ concurrent-ruby (~> 1.0)
121
+ rack (> 1, < 3)
122
+ sprockets-rails (3.2.2)
123
+ actionpack (>= 4.0)
124
+ activesupport (>= 4.0)
125
+ sprockets (>= 3.0.0)
126
+ thor (1.0.1)
127
+ thread_safe (0.3.6)
128
+ tzinfo (1.2.7)
129
+ thread_safe (~> 0.1)
130
+ websocket-driver (0.7.3)
131
+ websocket-extensions (>= 0.1.0)
132
+ websocket-extensions (0.1.5)
133
+ zeitwerk (2.4.0)
134
+
135
+ PLATFORMS
136
+ ruby
137
+
138
+ DEPENDENCIES
139
+ encrypted_attribute!
140
+ rake (~> 12.0)
141
+
142
+ BUNDLED WITH
143
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Trae Robrock
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # EncryptedAttribute
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/encrypted_attribute`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'encrypted_attribute'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install encrypted_attribute
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/encrypted_attribute.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "encrypted_attribute"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/encrypted_attribute/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "encrypted_attribute"
5
+ spec.version = EncryptedAttribute::VERSION
6
+ spec.authors = ["Trae Robrock"]
7
+ spec.email = ["trobrock@gmail.com"]
8
+
9
+ spec.summary = %q{Bare bones attr encrypted for Rails}
10
+ spec.description = %q{Bare bones attr encrypted for Rails}
11
+ spec.homepage = "https://github.com/trobrock/encrypted_attribute"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/trobrock/encrypted_attribute"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency 'activesupport'
28
+ spec.add_dependency 'rails'
29
+ end
@@ -0,0 +1,38 @@
1
+ require "encrypted_attribute/version"
2
+
3
+ require 'activesupport/concern'
4
+ require 'activesupport/message_encryptor'
5
+
6
+ module EncryptedAttribute
7
+ extend ActiveSupport::Concern
8
+
9
+ class_methods do
10
+ def attr_encrypted(attr)
11
+ define_method(attr) do
12
+ value = instance_variable_get("@#{attr}")
13
+ return value if value
14
+
15
+ raw_value = public_send("encrypted_#{attr}".to_sym)
16
+ return nil unless raw_value
17
+
18
+ instance_variable_set "@#{attr}", encryptor.decrypt_and_verify(raw_value)
19
+ end
20
+
21
+ define_method("#{attr}=") do |new_value|
22
+ value = encryptor.encrypt_and_sign(new_value)
23
+ instance_variable_set("@#{attr}", new_value)
24
+ public_send("encrypted_#{attr}=", value)
25
+ end
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def encryptor
32
+ @encryptor = ActiveSupport::MessageEncryptor.new(encryptor_key)
33
+ end
34
+
35
+ def encryptor_key
36
+ ENV['RAILS_MASTER_KEY'] || File.read(Rails.application.config.credentials.key_path)
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module EncryptedAttribute
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encrypted_attribute
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Trae Robrock
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Bare bones attr encrypted for Rails
42
+ email:
43
+ - trobrock@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - encrypted_attribute.gemspec
57
+ - lib/encrypted_attribute.rb
58
+ - lib/encrypted_attribute/version.rb
59
+ homepage: https://github.com/trobrock/encrypted_attribute
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/trobrock/encrypted_attribute
64
+ source_code_uri: https://github.com/trobrock/encrypted_attribute
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.3.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.1.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Bare bones attr encrypted for Rails
84
+ test_files: []