manageiq-password 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +0 -2
- data/bin/console +3 -1
- data/lib/manageiq-password.rb +1 -0
- data/lib/manageiq/password/password_mixin.rb +55 -0
- data/lib/manageiq/password/version.rb +1 -1
- data/manageiq-password.gemspec +1 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1eba2adf883b719e5de3e9f5d5161f2e40f40330
|
4
|
+
data.tar.gz: 4f20ffe2f0bd6995145737d85ce3a0a444eba276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02be3c11b09fa84571da0a682460e8c891516248b58eb3c4c079df59a5248ebdefb0a4dc5025e635ea5d380e0690068e1467ac71afebba2cc6d75924602dcf02
|
7
|
+
data.tar.gz: b0f2f855b9ad52d3c0eadcffb9bdb16271d3af9e745589ab9ea739b17c89fa309a4bef2782979dbace7af4bd5e2e1a4fa281c9e37c3188ea5f564f758ca7b1e6
|
data/Gemfile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "manageiq
|
4
|
+
require "manageiq-password"
|
5
|
+
|
6
|
+
ManageIQ::Password.key_root = File.expand_path("../spec/support", __dir__)
|
5
7
|
|
6
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
9
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -0,0 +1 @@
|
|
1
|
+
require "manageiq/password"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ManageIQ
|
2
|
+
class Password
|
3
|
+
module PasswordMixin
|
4
|
+
def self.included(other)
|
5
|
+
other.extend(ClassMethods)
|
6
|
+
|
7
|
+
other.class_attribute :encrypted_columns
|
8
|
+
other.encrypted_columns = []
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def encrypt_column(column)
|
13
|
+
# Given a column of "password", create 4 instance methods:
|
14
|
+
# password : Get the password in plain text
|
15
|
+
# password= : Set the password in plain text
|
16
|
+
# password_encrypted : Get the password in cryptext
|
17
|
+
# password_encrypted= : Set the password in cryptext
|
18
|
+
|
19
|
+
encrypted_columns << column.to_s
|
20
|
+
encrypted_columns << "#{column}_encrypted"
|
21
|
+
|
22
|
+
mod = generated_methods_for_password_mixin
|
23
|
+
|
24
|
+
mod.send(:define_method, column) do
|
25
|
+
val = send("#{column}_encrypted")
|
26
|
+
(val.nil? || val.empty?) ? val : MiqPassword.decrypt(val)
|
27
|
+
end
|
28
|
+
|
29
|
+
mod.send(:define_method, "#{column}=") do |val|
|
30
|
+
val = MiqPassword.try_encrypt(val) unless val.nil? || val.empty?
|
31
|
+
send("#{column}_encrypted=", val)
|
32
|
+
end
|
33
|
+
|
34
|
+
mod.send(:define_method, "#{column}_encrypted") do
|
35
|
+
read_attribute(column)
|
36
|
+
end
|
37
|
+
|
38
|
+
mod.send(:define_method, "#{column}_encrypted=") do |val|
|
39
|
+
write_attribute(column, val)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def generated_methods_for_password_mixin
|
46
|
+
@generated_methods_for_password_mixin ||= begin
|
47
|
+
mod = const_set(:GeneratedMethodsForPasswordMixin, Module.new)
|
48
|
+
include mod
|
49
|
+
mod
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/manageiq-password.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "manageiq/password/version"
|
@@ -19,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
19
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
19
|
spec.require_paths = ["lib"]
|
21
20
|
|
22
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
23
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
24
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-password
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,9 @@ files:
|
|
86
86
|
- Rakefile
|
87
87
|
- bin/console
|
88
88
|
- bin/setup
|
89
|
+
- lib/manageiq-password.rb
|
89
90
|
- lib/manageiq/password.rb
|
91
|
+
- lib/manageiq/password/password_mixin.rb
|
90
92
|
- lib/manageiq/password/version.rb
|
91
93
|
- manageiq-password.gemspec
|
92
94
|
homepage: https://github.com/ManageIQ/manageiq-password
|
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
111
|
version: '0'
|
110
112
|
requirements: []
|
111
113
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.14.3
|
113
115
|
signing_key:
|
114
116
|
specification_version: 4
|
115
117
|
summary: A simple encryption util for storing passwords in a database.
|