keyrack 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -3,6 +3,52 @@
3
3
  Keyrack is a simple password manager with local or remote storage and RSA
4
4
  encryption.
5
5
 
6
+ == Installation
7
+
8
+ gem install keyrack
9
+
10
+ == Configuration
11
+
12
+ === Format
13
+
14
+ The configuration file is a YAML file that requires the following data:
15
+ * *key*: path to the RSA file you want to use
16
+ * *store*: options for store (see below)
17
+
18
+ === Store types
19
+
20
+ * *filesystem*
21
+ * Required options:
22
+ * *path*: path to the keyrack database
23
+ * +ssh+
24
+ * Required options:
25
+ * *host*: host name
26
+ * *user*: user name
27
+ * *path*: path to the keyrack database on remote host
28
+
29
+ === Examples
30
+
31
+ Filesystem example
32
+ store:
33
+ type: filesystem
34
+ path: ~/.keyrack/database
35
+ key: ~/.keyrack/id_rsa
36
+
37
+ SSH example
38
+ store:
39
+ type: ssh
40
+ host: example.com
41
+ user: foobar
42
+ path: ~/junk.dat
43
+ key: ~/.keyrack/id_rsa
44
+
45
+ == Usage
46
+
47
+ keyrack [-c path-to-config]
48
+
49
+ By default, keyrack will look for <b>~/.keyrack/config</b>. The database file
50
+ (merely a RSA-encrypted YAML file) will be created on save if it doesn't exist.
51
+
6
52
  == Contributing to keyrack
7
53
 
8
54
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,10 +1,10 @@
1
1
  module Keyrack
2
2
  class Database
3
3
  def initialize(config)
4
- store_config = config[:store].dup
5
- @store = Store[store_config.delete(:type)].new(store_config)
6
- key_path = File.expand_path(config[:key])
7
- @key = OpenSSL::PKey::RSA.new(File.read(key_path), config[:password])
4
+ store_config = config['store'].dup
5
+ @store = Store[store_config.delete('type')].new(store_config)
6
+ key_path = File.expand_path(config['key'])
7
+ @key = OpenSSL::PKey::RSA.new(File.read(key_path), config['password'])
8
8
  @data = decrypt
9
9
  end
10
10
 
@@ -1,12 +1,16 @@
1
1
  module Keyrack
2
2
  class Runner
3
3
  def initialize(argv)
4
+ options = {
5
+ :config_path => "~/.keyrack/config"
6
+ }
4
7
  OptionParser.new do |opts|
5
- opts.on("-c", "--config FILE", "Specify configuration file") do |f|
6
- @options = YAML.load_file(f)
8
+ opts.on("-c", "--config [FILE]", "Specify configuration file (Default: #{options[:config_path]}") do |f|
9
+ options[:config_path] = f
7
10
  end
8
11
  end.parse(argv)
9
12
 
13
+ @options = YAML.load_file(File.expand_path(options[:config_path]))
10
14
  @ui = UI::Console.new
11
15
  password = @ui.get_password
12
16
  @database = Database.new(@options.merge(:password => password))
data/lib/keyrack/store.rb CHANGED
@@ -2,8 +2,8 @@ module Keyrack
2
2
  module Store
3
3
  def self.[](name)
4
4
  case name
5
- when :filesystem then Filesystem
6
- when :ssh then SSH
5
+ when :filesystem, 'filesystem' then Filesystem
6
+ when :ssh, 'ssh' then SSH
7
7
  end
8
8
  end
9
9
  end
@@ -2,7 +2,7 @@ module Keyrack
2
2
  module Store
3
3
  class Filesystem
4
4
  def initialize(options)
5
- @path = File.expand_path(options[:path])
5
+ @path = File.expand_path(options['path'])
6
6
  end
7
7
 
8
8
  def read
@@ -2,9 +2,9 @@ module Keyrack
2
2
  module Store
3
3
  class SSH
4
4
  def initialize(options)
5
- @host = options[:host]
6
- @user = options[:user]
7
- @path = options[:path]
5
+ @host = options['host']
6
+ @user = options['user']
7
+ @path = options['path']
8
8
  end
9
9
 
10
10
  def read
@@ -1,4 +1,4 @@
1
- :store:
2
- :type: :filesystem
3
- :path: /tmp/keyrack.dat
4
- :key: test/fixtures/id_rsa
1
+ 'store':
2
+ 'type': 'filesystem'
3
+ 'path': /tmp/keyrack.dat
4
+ 'key': test/fixtures/id_rsa
@@ -5,19 +5,19 @@ module Keyrack
5
5
  class TestFilesystem < Test::Unit::TestCase
6
6
  def test_read
7
7
  path = fixture_path('foo.txt')
8
- store = Filesystem.new(:path => path)
8
+ store = Filesystem.new('path' => path)
9
9
  assert_equal File.read(path), store.read
10
10
  end
11
11
 
12
12
  def test_write
13
13
  path = get_tmpname
14
- store = Filesystem.new(:path => path)
14
+ store = Filesystem.new('path' => path)
15
15
  store.write("foobar")
16
16
  assert_equal "foobar", File.read(path)
17
17
  end
18
18
 
19
19
  def test_read_returns_nil_for_non_existant_file
20
- store = Filesystem.new(:path => 'blargityblargh')
20
+ store = Filesystem.new('path' => 'blargityblargh')
21
21
  assert_nil store.read
22
22
  end
23
23
  end
@@ -4,13 +4,13 @@ module Keyrack
4
4
  module Store
5
5
  class TestSSH < Test::Unit::TestCase
6
6
  def test_read
7
- store = SSH.new(:host => 'example.com', :user => 'dude', :path => 'foo.txt')
7
+ store = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
8
8
  Net::SCP.expects(:download!).with("example.com", "dude", "foo.txt").returns("foo")
9
9
  assert_equal "foo", store.read
10
10
  end
11
11
 
12
12
  def test_write
13
- store = SSH.new(:host => 'example.com', :user => 'dude', :path => 'foo.txt')
13
+ store = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
14
14
  Net::SCP.expects(:upload!).with do |host, user, local, remote|
15
15
  host == 'example.com' && user == 'dude' && local.is_a?(StringIO) &&
16
16
  local.read == "foo" && remote == "foo.txt"
@@ -19,7 +19,7 @@ module Keyrack
19
19
  end
20
20
 
21
21
  def test_read_returns_nil_for_non_existant_file
22
- store = SSH.new(:host => 'example.com', :user => 'dude', :path => 'foo.txt')
22
+ store = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
23
23
  Net::SCP.expects(:download!).with("example.com", "dude", "foo.txt").raises(Net::SCP::Error)
24
24
  assert_nil store.read
25
25
  end
@@ -5,9 +5,9 @@ module Keyrack
5
5
  def setup
6
6
  @path = get_tmpname
7
7
  @database = Keyrack::Database.new({
8
- :store => { :type => :filesystem, :path => @path },
9
- :key => fixture_path('id_rsa'),
10
- :password => 'secret'
8
+ 'store' => { 'type' => 'filesystem', 'path' => @path },
9
+ 'key' => fixture_path('id_rsa'),
10
+ 'password' => 'secret'
11
11
  })
12
12
  @database.add('Twitter', 'username', 'password')
13
13
  @database.save
@@ -23,9 +23,9 @@ module Keyrack
23
23
 
24
24
  def test_reading_existing_database
25
25
  database = Keyrack::Database.new({
26
- :store => { :type => :filesystem, :path => @path },
27
- :key => fixture_path('id_rsa'),
28
- :password => 'secret'
26
+ 'store' => { 'type' => 'filesystem', 'path' => @path },
27
+ 'key' => fixture_path('id_rsa'),
28
+ 'password' => 'secret'
29
29
  })
30
30
  expected = {:username => 'username', :password => 'password'}
31
31
  assert_equal(expected, database.get('Twitter'))
@@ -4,8 +4,8 @@ module Keyrack
4
4
  class TestRunner < Test::Unit::TestCase
5
5
  def test_console
6
6
  config = {
7
- :store => { :type => :filesystem, :path => 'foobar' },
8
- :key => fixture_path('id_rsa')
7
+ 'store' => { 'type' => 'filesystem', 'path' => 'foobar' },
8
+ 'key' => fixture_path('id_rsa')
9
9
  }
10
10
  config_path = get_tmpname
11
11
  File.open(config_path, 'w') { |f| f.print(config.to_yaml) }
@@ -4,10 +4,12 @@ module Keyrack
4
4
  class TestStore < Test::Unit::TestCase
5
5
  def test_get_filesystem
6
6
  assert_equal Store::Filesystem, Store[:filesystem]
7
+ assert_equal Store::Filesystem, Store['filesystem']
7
8
  end
8
9
 
9
10
  def test_get_ssh
10
11
  assert_equal Store::SSH, Store[:ssh]
12
+ assert_equal Store::SSH, Store['ssh']
11
13
  end
12
14
  end
13
15
  end
@@ -6,9 +6,9 @@ module Keyrack
6
6
  def setup
7
7
  @path = get_tmpname
8
8
  @database = Database.new({
9
- :store => { :type => :filesystem, :path => @path },
10
- :key => fixture_path('id_rsa'),
11
- :password => 'secret'
9
+ 'store' => { 'type' => 'filesystem', 'path' => @path },
10
+ 'key' => fixture_path('id_rsa'),
11
+ 'password' => 'secret'
12
12
  })
13
13
  @database.add('Twitter', 'username', 'password')
14
14
  @database.save
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Stephens
@@ -274,7 +274,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
274
  requirements:
275
275
  - - ">="
276
276
  - !ruby/object:Gem::Version
277
- hash: -93442259
277
+ hash: -3950856831119826099
278
278
  segments:
279
279
  - 0
280
280
  version: "0"