omnivault 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d05e1845311fc4dc9cd6d93558626016bfb0d45
4
+ data.tar.gz: 075296794303a383d635149e4663b79570c6f476
5
+ SHA512:
6
+ metadata.gz: d4f62d3924e3235a558c8892bcbb0b618244eae0fb86c86c93a88d8c9b31846cfd90ce5a00e083421bb0ac9dc39f5535e570da66347968f7552f247a8bf4c926
7
+ data.tar.gz: 2f203420cc8d7d8db006de6347ebcfe9fa834a89ea28afb083dcf91d09ed81c46d142ca9fbe79dd602a98125cb15d23e497f6ddf35813626f233ef8e164b1343
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - "2.1"
3
+ - 2.0.0
4
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omnivault.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Aptible, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Omnivault
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/omnivault.png)](https://rubygems.org/gems/omnivault)
4
+ [![Build Status](https://travis-ci.org/aptible/omnivault.png?branch=master)](https://travis-ci.org/aptible/omnivault)
5
+ [![Dependency Status](https://gemnasium.com/aptible/omnivault.png)](https://gemnasium.com/aptible/omnivault)
6
+
7
+ A Ruby library to abstract keychain functionality for storing and retrieiving arbitrary secrets from a variety of password vaults.
8
+
9
+ Omnivault supports simple key-value secret retrieval with the following password vaults:
10
+
11
+ * Apple OS X Keychain
12
+ * pws (a CLI-based vault)
13
+
14
+ Additionally, it supports automatic credential setup for the following libraries:
15
+
16
+ * AWS Ruby SDK (`aws-sdk-v1`, `aws-sdk`)
17
+
18
+ ## Installation
19
+
20
+ Add the following line to your application's Gemfile.
21
+
22
+ gem 'omnivault'
23
+
24
+ And then run `bundle install`.
25
+
26
+ ## Usage
27
+
28
+ To initialize the the Omnivault, run:
29
+
30
+ ```ruby
31
+ omnivault = Omnivault.autodetect
32
+ ```
33
+
34
+ This will determine an appropriate provider using the following logic:
35
+
36
+ * If the ENV variable `VAULT` is set, it will use that provider, i.e.,
37
+ - Apple Keychain for `VAULT=apple`
38
+ - PWS for `VAULT=pws`
39
+ * If no ENV variable is set, it will try to use Apple Keychain first, and fall back to PWS if not on Apple OS X.
40
+
41
+ Then, to use Omnivault, you can:
42
+
43
+ ```ruby
44
+ omnivault.store('foo', 'bar')
45
+ omnivault.entries
46
+ # => { "foo" => "bar" }
47
+ omnivault.fetch("foo")
48
+ # => "bar"
49
+ ```
50
+
51
+ ## TODO
52
+
53
+ * Add support for 1Password keychains.
54
+ * Write RSpec unit tests.
55
+ * Remove dependence on AWS-specific gems directly
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork the project.
60
+ 1. Commit your changes, with specs.
61
+ 1. Ensure that your code passes specs (`rake spec`) and meets Aptible's Ruby style guide (`rake rubocop`).
62
+ 1. Create a new pull request on GitHub.
63
+
64
+ ## Copyright and License
65
+
66
+ MIT License, see [LICENSE](LICENSE.md) for details.
67
+
68
+ Copyright (c) 2015 [Aptible](https://www.aptible.com), Frank Macreery, and contributors.
69
+
70
+ [<img src="https://s.gravatar.com/avatar/f7790b867ae619ae0496460aa28c5861?s=60" style="border-radius: 50%;" alt="@fancyremarker" />](https://github.com/fancyremarker)
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'aptible/tasks'
4
+ Aptible::Tasks.load_tasks
data/lib/omnivault.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'omnivault/version'
2
+
3
+ require_relative 'omnivault/abstract_vault'
4
+ require_relative 'omnivault/apple_keychain'
5
+ require_relative 'omnivault/pws'
6
+
7
+ module Omnivault
8
+ def self.autodetect
9
+ Omnivault::AbstractVault.from_env || Omnivault::AbstractVault.for_platform
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ module Omnivault
2
+ class AbstractVault
3
+ def self.from_env
4
+ case ENV['VAULT']
5
+ when 'apple', 'AppleKeychain'
6
+ AppleKeychain.new
7
+ when 'pws', 'PWS'
8
+ PWS.new
9
+ end
10
+ end
11
+
12
+ def self.for_platform
13
+ AppleKeychain.new
14
+ rescue LoadError
15
+ PWS.new
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ module Omnivault
2
+ class AppleKeychain < AbstractVault
3
+ def initialize
4
+ # Need to require within initializer, to avoid LoadError on
5
+ # non-Apple platforms
6
+ require 'keychain'
7
+ require 'aws-keychain-util/credential_provider'
8
+ end
9
+
10
+ def entries
11
+ keychain = open_or_create_keychain
12
+ Hash[keychain.generic_passwords.all.map do |item|
13
+ [item.label, item.password]
14
+ end]
15
+ end
16
+
17
+ def fetch(key)
18
+ entries[key]
19
+ end
20
+
21
+ def store(key, value)
22
+ keychain = open_or_create_keychain
23
+ if (entry = keychain.generic_passwords.where(label: key).all.first)
24
+ entry.password = value
25
+ else
26
+ keychain.generic_passwords.create(
27
+ service: key,
28
+ label: key,
29
+ password: value
30
+ )
31
+ end
32
+ end
33
+
34
+ def configure_aws!
35
+ provider = ::AwsKeychainUtil::CredentialProvider.new('default', 'aws')
36
+ AWS.config(credential_provider: provider)
37
+ end
38
+
39
+ private
40
+
41
+ def open_or_create_keychain(name = 'aptible-cookbook')
42
+ keychain = Keychain.open("#{name}.keychain")
43
+ return keychain if keychain.exists?
44
+
45
+ Keychain.create("#{name}.keychain")
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ require 'aws/pws'
2
+ require 'aws/pws/credential_provider'
3
+
4
+ module Omnivault
5
+ class PWS < AbstractVault
6
+ attr_accessor :client
7
+
8
+ def entries
9
+ @client ||= AWS::PWS::Client.new
10
+ Hash[@client.raw_data.map { |k, v| [k, v[:password]] }]
11
+ end
12
+
13
+ def fetch(key)
14
+ entries[key]
15
+ end
16
+
17
+ def store(key, value)
18
+ @client ||= AWS::PWS::Client.new
19
+ @client.cli.add(key, value)
20
+ end
21
+
22
+ def configure_aws!
23
+ provider = AWS::PWS::CredentialProvider.new
24
+ AWS.config(credential_provider: provider)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Omnivault
2
+ VERSION = '0.1.0'
3
+ end
data/omnivault.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'English'
6
+ require 'omnivault/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'omnivault'
10
+ spec.version = Omnivault::VERSION
11
+ spec.authors = ['Frank Macreery']
12
+ spec.email = ['frank@macreery.com']
13
+ spec.description = 'Abstract password vault for multiple providers'
14
+ spec.summary = 'Abstract password vault for multiple providers'
15
+ spec.homepage = 'https://github.com/aptible/omnivault'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($RS)
19
+ spec.test_files = spec.files.grep(%r{^spec/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'aws-keychain-util'
23
+ spec.add_dependency 'aws-pws'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.8'
26
+ spec.add_development_dependency 'aptible-tasks'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec', '~> 2.0'
29
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ # Load shared spec files
5
+ Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each do |file|
6
+ require file
7
+ end
8
+
9
+ # Require library up front
10
+ require 'omnivault'
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omnivault
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Frank Macreery
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-keychain-util
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: aws-pws
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
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aptible-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ description: Abstract password vault for multiple providers
98
+ email:
99
+ - frank@macreery.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.md
109
+ - README.md
110
+ - Rakefile
111
+ - lib/omnivault.rb
112
+ - lib/omnivault/abstract_vault.rb
113
+ - lib/omnivault/apple_keychain.rb
114
+ - lib/omnivault/pws.rb
115
+ - lib/omnivault/version.rb
116
+ - omnivault.gemspec
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/aptible/omnivault
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.2
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Abstract password vault for multiple providers
142
+ test_files:
143
+ - spec/spec_helper.rb