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 +46 -0
- data/VERSION +1 -1
- data/lib/keyrack/database.rb +4 -4
- data/lib/keyrack/runner.rb +6 -2
- data/lib/keyrack/store.rb +2 -2
- data/lib/keyrack/store/filesystem.rb +1 -1
- data/lib/keyrack/store/ssh.rb +3 -3
- data/test/fixtures/config.yml +4 -4
- data/test/keyrack/store/test_filesystem.rb +3 -3
- data/test/keyrack/store/test_ssh.rb +3 -3
- data/test/keyrack/test_database.rb +6 -6
- data/test/keyrack/test_runner.rb +2 -2
- data/test/keyrack/test_store.rb +2 -0
- data/test/keyrack/ui/test_console.rb +3 -3
- metadata +3 -3
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.
|
1
|
+
0.1.1
|
data/lib/keyrack/database.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Keyrack
|
2
2
|
class Database
|
3
3
|
def initialize(config)
|
4
|
-
store_config = config[
|
5
|
-
@store = Store[store_config.delete(
|
6
|
-
key_path = File.expand_path(config[
|
7
|
-
@key = OpenSSL::PKey::RSA.new(File.read(key_path), 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'])
|
8
8
|
@data = decrypt
|
9
9
|
end
|
10
10
|
|
data/lib/keyrack/runner.rb
CHANGED
@@ -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
|
-
|
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
data/lib/keyrack/store/ssh.rb
CHANGED
data/test/fixtures/config.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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'))
|
data/test/keyrack/test_runner.rb
CHANGED
@@ -4,8 +4,8 @@ module Keyrack
|
|
4
4
|
class TestRunner < Test::Unit::TestCase
|
5
5
|
def test_console
|
6
6
|
config = {
|
7
|
-
|
8
|
-
|
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) }
|
data/test/keyrack/test_store.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
11
|
-
|
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
|
-
-
|
9
|
-
version: 0.1.
|
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: -
|
277
|
+
hash: -3950856831119826099
|
278
278
|
segments:
|
279
279
|
- 0
|
280
280
|
version: "0"
|