with_cred 0.0.1

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.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in with_cred.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 John Cant
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,56 @@
1
+ # WithCred
2
+
3
+ Put your credentials in a standard convenient place. This place is an
4
+ encrypted tarball, which should be decrypted on deploy. If you like, you
5
+ can commit them into your CVS, but this is not recommended
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'with_cred'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install with_cred
20
+
21
+ ## Usage
22
+
23
+ (1) Add the directory credentials/ and credentials.* to your .gitignore
24
+ (2) Put your facebook credentials as follows in
25
+ credentials/facebook.yaml
26
+ api_token: "DEADBEEF543254738o25y437"
27
+ api_secret: "FEEBDAED3215432543523452"
28
+ (3) Add `config.credentials_mode = "production"` to your config/environments/production.rb
29
+ (4) Access from ruby
30
+ ```ruby
31
+ WithCred.entials(:facebook) do |credentials|
32
+ #Set up the facebook API stuff
33
+ end
34
+ ```
35
+
36
+ Tasks
37
+ ```
38
+ # Decrypt, asking for password
39
+ rake credentials:decrypt
40
+
41
+ # Decrypt, Looking in the file /etc/yourapp/.secret for the password
42
+ rake credentials:decrypt[/etc/yourapp/.secret]
43
+
44
+ # Encrypt, asking for the password
45
+ rake credentials:encrypt
46
+
47
+ # Encrypt, Looking in the file /etc/yourapp/.secret for the password
48
+ rake credentials:encrypt[/etc/yourapp/.secret]
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require 'rails'
2
+
3
+ module WithCred
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ rake_tasks do
7
+ Dir[File.expand_path('../tasks/*.rake', __FILE__)].each { |f| load f }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ namespace :credentials do
2
+
3
+ desc "Decrypt the set of credentials"
4
+ task :decrypt, :passphrase_file do |t, args|
5
+ passphrase_options = "--passphrase-file #{args[:passphrase_file]}" unless args[:passphrase_file].blank?
6
+ puts args.inspect
7
+
8
+ `mkdir credentials/` unless File.exists?("credentials")
9
+ `gpg --yes #{passphrase_options} --no-use-agent --no-tty -o credentials/credentials.tar.gz --decrypt credentials.tar.gz.gpg`
10
+ `tar -C credentials -xf credentials/credentials.tar.gz`
11
+
12
+ end
13
+
14
+ desc "Encrypt the credentials"
15
+ task :encrypt, :passphrase_file do |t, args|
16
+ passphrase_options = "--passphrase-file #{args[:passphrase_file]}" unless args[:passphrase_file].blank?
17
+
18
+ `cd credentials && tar -czf credentials.tar.gz ./*`
19
+ `gpg #{passphrase_options} -o credentials.tar.gz.gpg -c credentials/credentials.tar.gz`
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ module WithCred
2
+ VERSION = "0.0.1"
3
+ end
data/lib/with_cred.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "with_cred/version"
2
+
3
+ class CredentialsNotFoundError < StandardError ; end
4
+
5
+ module WithCred
6
+ def self.entials_for(file)
7
+
8
+ # This method ignores the block if the credentials are required, and we are not supposed to need them.
9
+ # Passes the credentials into the block as read from the credentials YAML file at "#{Rails.root}/credentials/#{file}.yaml"
10
+
11
+ if (allowed = (Rails.application.config.credentials_mode == "production"))
12
+
13
+ credentials = nil
14
+
15
+ begin
16
+ credentials = YAML::load_file("#{Rails.root}/credentials/#{file.to_s}.yaml")
17
+ rescue
18
+ raise CredentialsNotFoundError
19
+ end
20
+
21
+ yield credentials
22
+ end
23
+
24
+ return allowed
25
+
26
+ end
27
+ end
28
+
data/with_cred.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'with_cred/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "with_cred"
8
+ gem.version = WithCred::VERSION
9
+ gem.authors = ["John Cant"]
10
+ gem.email = ["a.johncant@gmail.com"]
11
+ gem.description = %q{Simple credentials storage}
12
+ gem.summary = %q{bla}
13
+ gem.homepage = "https://github.com/johncant/with_cred"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: with_cred
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Cant
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Simple credentials storage
15
+ email:
16
+ - a.johncant@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/with_cred.rb
27
+ - lib/with_cred/railtie.rb
28
+ - lib/with_cred/tasks/credentials.rake
29
+ - lib/with_cred/version.rb
30
+ - with_cred.gemspec
31
+ homepage: https://github.com/johncant/with_cred
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: bla
55
+ test_files: []
56
+ has_rdoc: