keyring 0.1.0 → 0.2.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE +20 -0
- data/README.md +62 -70
- data/Rakefile +10 -15
- data/bin/keyring +12 -0
- data/keyring.gemspec +28 -0
- data/lib/keyring.rb +22 -13
- data/lib/keyring/backend.rb +42 -0
- data/lib/keyring/backends/macosx_keychain.rb +91 -0
- data/lib/keyring/backends/memory.rb +29 -0
- data/lib/keyring/cli.rb +79 -0
- data/lib/keyring/version.rb +6 -0
- data/test/keyring_tests.rb +7 -0
- data/test/test_backend.rb +38 -0
- data/test/test_backend_macosx_keychain.rb +73 -0
- data/test/test_backend_memory.rb +43 -0
- data/test/test_cli.rb +58 -0
- data/test/test_keyring.rb +36 -0
- data/test/testcmds/macosx/binary +1 -0
- data/test/testcmds/macosx/emptything +1 -0
- data/test/testcmds/macosx/random +1 -0
- data/test/testcmds/macosx/security-delete +27 -0
- data/test/testcmds/macosx/security-find +26 -0
- data/test/testcmds/macosx/security-findempty +26 -0
- data/test/testcmds/macosx/security-findhex +26 -0
- data/test/testcmds/macosx/security-notfound +6 -0
- data/test/testcmds/macosx/security-righthelp +51 -0
- data/test/testcmds/macosx/security-wronghelp +7 -0
- metadata +129 -59
- data/History.txt +0 -4
- data/lib/keyring/Keyring.rb +0 -95
- data/lib/keyring/SimpleKeyring.rb +0 -38
- data/spec/keyring_spec.rb +0 -129
- data/spec/spec_helper.rb +0 -15
- data/version.txt +0 -1
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# keyring: System keyring abstraction library
|
3
|
+
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
4
|
+
|
5
|
+
# The help output really is indented with spaces like this
|
6
|
+
cat <<-EOF
|
7
|
+
help Show all commands, or show usage for a command.
|
8
|
+
list-keychains Display or manipulate the keychain search list.
|
9
|
+
default-keychain Display or set the default keychain.
|
10
|
+
login-keychain Display or set the login keychain.
|
11
|
+
create-keychain Create keychains and add them to the search list.
|
12
|
+
delete-keychain Delete keychains and remove them from the search list.
|
13
|
+
lock-keychain Lock the specified keychain.
|
14
|
+
unlock-keychain Unlock the specified keychain.
|
15
|
+
set-keychain-settings Set settings for a keychain.
|
16
|
+
set-keychain-password Set password for a keychain.
|
17
|
+
show-keychain-info Show the settings for keychain.
|
18
|
+
dump-keychain Dump the contents of one or more keychains.
|
19
|
+
create-keypair Create an asymmetric key pair.
|
20
|
+
add-generic-password Add a generic password item.
|
21
|
+
add-internet-password Add an internet password item.
|
22
|
+
add-certificates Add certificates to a keychain.
|
23
|
+
find-generic-password Find a generic password item.
|
24
|
+
delete-generic-password Delete a generic password item.
|
25
|
+
find-internet-password Find an internet password item.
|
26
|
+
delete-internet-password Delete an internet password item.
|
27
|
+
find-certificate Find a certificate item.
|
28
|
+
find-identity Find an identity (certificate + private key).
|
29
|
+
delete-certificate Delete a certificate from a keychain.
|
30
|
+
set-identity-preference Set the preferred identity to use for a service.
|
31
|
+
get-identity-preference Get the preferred identity to use for a service.
|
32
|
+
create-db Create a db using the DL.
|
33
|
+
export Export items from a keychain.
|
34
|
+
import Import items into a keychain.
|
35
|
+
cms Encode or decode CMS messages.
|
36
|
+
install-mds Install (or re-install) the MDS database.
|
37
|
+
add-trusted-cert Add trusted certificate(s).
|
38
|
+
remove-trusted-cert Remove trusted certificate(s).
|
39
|
+
dump-trust-settings Display contents of trust settings.
|
40
|
+
user-trust-settings-enable Display or manipulate user-level trust settings.
|
41
|
+
trust-settings-export Export trust settings.
|
42
|
+
trust-settings-import Import trust settings.
|
43
|
+
verify-cert Verify certificate(s).
|
44
|
+
authorize Perform authorization operations.
|
45
|
+
authorizationdb Make changes to the authorization policy database.
|
46
|
+
|
47
|
+
execute-with-privileges Execute tool with privileges.
|
48
|
+
leaks Run /usr/bin/leaks on this process.
|
49
|
+
error Display a descriptive message for the given error code(s).
|
50
|
+
create-filevaultmaster-keychain Create a keychain containing a key pair for FileVault recovery use.
|
51
|
+
EOF
|
metadata
CHANGED
@@ -1,77 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: keyring
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
6
|
+
authors:
|
7
|
+
- Jason Heiss
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
18
35
|
prerelease: false
|
19
|
-
|
20
|
-
|
21
|
-
|
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: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
22
45
|
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
25
48
|
type: :development
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: This library provides a easy way to access the system keyring service
|
70
|
+
from ruby
|
71
|
+
email:
|
72
|
+
- jheiss@aput.net
|
73
|
+
executables:
|
74
|
+
- keyring
|
33
75
|
extensions: []
|
34
|
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
-
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
39
81
|
- README.md
|
40
82
|
- Rakefile
|
83
|
+
- bin/keyring
|
84
|
+
- keyring.gemspec
|
41
85
|
- lib/keyring.rb
|
42
|
-
- lib/keyring/
|
43
|
-
- lib/keyring/
|
44
|
-
-
|
45
|
-
-
|
46
|
-
- version.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
86
|
+
- lib/keyring/backend.rb
|
87
|
+
- lib/keyring/backends/macosx_keychain.rb
|
88
|
+
- lib/keyring/backends/memory.rb
|
89
|
+
- lib/keyring/cli.rb
|
90
|
+
- lib/keyring/version.rb
|
91
|
+
- test/keyring_tests.rb
|
92
|
+
- test/test_backend.rb
|
93
|
+
- test/test_backend_macosx_keychain.rb
|
94
|
+
- test/test_backend_memory.rb
|
95
|
+
- test/test_cli.rb
|
96
|
+
- test/test_keyring.rb
|
97
|
+
- test/testcmds/macosx/binary
|
98
|
+
- test/testcmds/macosx/emptything
|
99
|
+
- test/testcmds/macosx/random
|
100
|
+
- test/testcmds/macosx/security-delete
|
101
|
+
- test/testcmds/macosx/security-find
|
102
|
+
- test/testcmds/macosx/security-findempty
|
103
|
+
- test/testcmds/macosx/security-findhex
|
104
|
+
- test/testcmds/macosx/security-notfound
|
105
|
+
- test/testcmds/macosx/security-righthelp
|
106
|
+
- test/testcmds/macosx/security-wronghelp
|
107
|
+
homepage: https://github.com/jheiss/keyring
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
51
111
|
post_install_message:
|
52
|
-
rdoc_options:
|
53
|
-
|
54
|
-
- README.md
|
55
|
-
require_paths:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
56
114
|
- lib
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
|
59
|
-
requirements:
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
60
117
|
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version:
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
|
65
|
-
requirements:
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
66
122
|
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
requirements: []
|
70
|
-
|
71
|
-
|
72
|
-
rubygems_version: 1.6.2
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.2.0.rc.1
|
73
128
|
signing_key:
|
74
|
-
specification_version:
|
75
|
-
summary:
|
76
|
-
test_files:
|
77
|
-
|
129
|
+
specification_version: 4
|
130
|
+
summary: Store and access your passwords safely
|
131
|
+
test_files:
|
132
|
+
- test/keyring_tests.rb
|
133
|
+
- test/test_backend.rb
|
134
|
+
- test/test_backend_macosx_keychain.rb
|
135
|
+
- test/test_backend_memory.rb
|
136
|
+
- test/test_cli.rb
|
137
|
+
- test/test_keyring.rb
|
138
|
+
- test/testcmds/macosx/binary
|
139
|
+
- test/testcmds/macosx/emptything
|
140
|
+
- test/testcmds/macosx/random
|
141
|
+
- test/testcmds/macosx/security-delete
|
142
|
+
- test/testcmds/macosx/security-find
|
143
|
+
- test/testcmds/macosx/security-findempty
|
144
|
+
- test/testcmds/macosx/security-findhex
|
145
|
+
- test/testcmds/macosx/security-notfound
|
146
|
+
- test/testcmds/macosx/security-righthelp
|
147
|
+
- test/testcmds/macosx/security-wronghelp
|
data/History.txt
DELETED
data/lib/keyring/Keyring.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Keyring
|
4
|
-
|
5
|
-
@keyring = nil
|
6
|
-
@backends = {}
|
7
|
-
|
8
|
-
# Registers a backend
|
9
|
-
def self.add_backend( name, backend )
|
10
|
-
@backends[name] = backend
|
11
|
-
end
|
12
|
-
|
13
|
-
# Changes the global default key-ring
|
14
|
-
def self.set_keyring( keyring )
|
15
|
-
raise ArgumentError, "Expected keyring" unless keyring.kind_of? Keyring
|
16
|
-
@keyring = keyring
|
17
|
-
end
|
18
|
-
|
19
|
-
# Returns the global default keyring
|
20
|
-
def self.keyring
|
21
|
-
unless @keyring
|
22
|
-
@backends.each_value do |backend|
|
23
|
-
keyring = backend.new
|
24
|
-
if keyring.supported?
|
25
|
-
@keyring = keyring
|
26
|
-
break if keyring.recommended?
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
@keyring
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.method_missing(name, *args, &block)
|
34
|
-
keyring.send(name, *args, &block)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Base class for all Keyrings.
|
38
|
-
# All keyring backends should inherit from this class.
|
39
|
-
class Keyring
|
40
|
-
# Determines if this keyring is supported by the current platform.
|
41
|
-
# @return [true, false] whether the keyring is supported by the current platform
|
42
|
-
def supported?
|
43
|
-
false
|
44
|
-
end
|
45
|
-
|
46
|
-
# Determines if this keyring is recommended by the current platform.
|
47
|
-
# @return [true, false] whether the keyring is recommended by the current platform
|
48
|
-
def recommended?
|
49
|
-
false
|
50
|
-
end
|
51
|
-
|
52
|
-
# Sets the user password for a certain service.
|
53
|
-
# @param [String] service the name of the service
|
54
|
-
# @param [String] username the name of the user
|
55
|
-
# @param [String, nil] password the new password to be stored
|
56
|
-
def set_password( service, username, password )
|
57
|
-
raise NotImplementedError, "Setting a password is not supported"
|
58
|
-
end
|
59
|
-
|
60
|
-
# Removes a user password for a certain service from the keyring.
|
61
|
-
# This is the same as setting the password to nil.
|
62
|
-
# @param [String] service the name of the service
|
63
|
-
# @param [String] username the name of the user
|
64
|
-
def delete_password( service, username )
|
65
|
-
set_password( service, username, nil )
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns the current user password for a certain service.
|
69
|
-
# @param [String] service the name of the service
|
70
|
-
# @param [String] username the name of the user
|
71
|
-
# @return [String, nil] the current password if available
|
72
|
-
def get_password( service, username )
|
73
|
-
raise NotImplementedError, "Retrieving a password is not supported"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
# load keyring
|
79
|
-
[".rbkeyringrc", "#{File.join(ENV['HOME'], '.rbkeyringrc')}"].each do |fname|
|
80
|
-
begin
|
81
|
-
File.open(fname, "r") do |f|
|
82
|
-
puts "load #{fname}"
|
83
|
-
config = YAML::load(f.read)
|
84
|
-
if config
|
85
|
-
kr_module = config["module"]
|
86
|
-
require kr_module
|
87
|
-
set_keyring(@backends[kr_module].new config["parameters"])
|
88
|
-
break
|
89
|
-
end
|
90
|
-
end
|
91
|
-
rescue IOError, Errno::ENOENT
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Keyring
|
2
|
-
|
3
|
-
# Simple keyring holding all keys in memory.
|
4
|
-
class SimpleKeyring < Keyring
|
5
|
-
def initialize
|
6
|
-
@services = {}
|
7
|
-
end
|
8
|
-
|
9
|
-
def supported?
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
def recommended?
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_password( service, username )
|
18
|
-
passwords = @services[service]
|
19
|
-
if passwords
|
20
|
-
passwords[username]
|
21
|
-
else
|
22
|
-
nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_password( service, username, password )
|
27
|
-
passwords = @services[service]
|
28
|
-
unless passwords
|
29
|
-
passwords = {}
|
30
|
-
@services[service] = passwords
|
31
|
-
end
|
32
|
-
passwords[username] = password
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
add_backend("simple", SimpleKeyring)
|
37
|
-
|
38
|
-
end
|
data/spec/keyring_spec.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
3
|
-
|
4
|
-
describe Keyring::Keyring, "after creation" do
|
5
|
-
before do
|
6
|
-
@keyring = Keyring::Keyring.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should not be supported" do
|
10
|
-
@keyring.supported?.should == false
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should not be recommended" do
|
14
|
-
@keyring.recommended?.should == false
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should raise an error when getting a password" do
|
18
|
-
lambda{@keyring.get_password("service", "user")}.should raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should raise an error when setting a password" do
|
22
|
-
lambda{@keyring.set_password("service", "user", "pass")}.should raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should raise an error when deleting a password" do
|
26
|
-
lambda{@keyring.delete_password("service", "user", "pass")}.should raise_error
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
describe Keyring::SimpleKeyring, "after creation" do
|
32
|
-
before do
|
33
|
-
@keyring = Keyring::SimpleKeyring.new
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should be supported" do
|
37
|
-
@keyring.supported?.should == true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should not be recommended" do
|
41
|
-
@keyring.recommended?.should == false
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should return nil when getting a password" do
|
45
|
-
@keyring.get_password("service", "user").should == nil
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should not raise an error when setting a password" do
|
49
|
-
lambda{@keyring.set_password("service", "user", "pass")}.should_not raise_error
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should not raise an error when deleting a password" do
|
53
|
-
lambda{@keyring.delete_password("service", "user")}.should_not raise_error
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
describe Keyring::SimpleKeyring, "with a single password" do
|
59
|
-
before do
|
60
|
-
@keyring = Keyring::SimpleKeyring.new
|
61
|
-
@keyring.set_password "service", "user", "pass"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should contain the password" do
|
65
|
-
@keyring.get_password("service", "user").should == "pass"
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should not contain a password for another user" do
|
69
|
-
@keyring.get_password("service", "user2").should == nil
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should not contain a password for another service" do
|
73
|
-
@keyring.get_password("service2", "user").should == nil
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should not contain a password after deletion" do
|
77
|
-
@keyring.delete_password("service", "user")
|
78
|
-
@keyring.get_password("service", "user").should == nil
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should contain the password after deletion of another user" do
|
82
|
-
@keyring.delete_password("service", "user2")
|
83
|
-
@keyring.get_password("service", "user").should == "pass"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should contain the password after deletion of another service" do
|
87
|
-
@keyring.delete_password("service2", "user")
|
88
|
-
@keyring.get_password("service", "user").should == "pass"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
describe Keyring::SimpleKeyring, "with a serveral passwords" do
|
94
|
-
before do
|
95
|
-
@keyring = Keyring::SimpleKeyring.new
|
96
|
-
@keyring.set_password "service", "user", "pass"
|
97
|
-
@keyring.set_password "service", "user2", "pass2"
|
98
|
-
@keyring.set_password "service2", "user", "pass21"
|
99
|
-
@keyring.set_password "service2", "user3", "pass23"
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should contain all passwords" do
|
103
|
-
@keyring.get_password("service", "user").should == "pass"
|
104
|
-
@keyring.get_password("service", "user2").should == "pass2"
|
105
|
-
@keyring.get_password("service2", "user").should == "pass21"
|
106
|
-
@keyring.get_password("service2", "user3").should == "pass23"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should not contain a password for another user" do
|
110
|
-
@keyring.get_password("service", "user3").should == nil
|
111
|
-
@keyring.get_password("service2", "user2").should == nil
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should not contain a password after deletion" do
|
115
|
-
@keyring.delete_password("service", "user")
|
116
|
-
@keyring.get_password("service", "user").should == nil
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should contain the password after deletion of another user" do
|
120
|
-
@keyring.delete_password("service", "user2")
|
121
|
-
@keyring.get_password("service", "user").should == "pass"
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should contain the password after deletion of another service" do
|
125
|
-
@keyring.delete_password("service2", "user")
|
126
|
-
@keyring.get_password("service", "user").should == "pass"
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|