github-auth 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +10 -1
- data/README.md +58 -31
- data/bin/gh-auth +1 -1
- data/github-auth.gemspec +2 -0
- data/lib/github/auth.rb +0 -1
- data/lib/github/auth/cli.rb +55 -21
- data/lib/github/auth/keys_file.rb +4 -3
- data/lib/github/auth/version.rb +1 -1
- data/spec/acceptance/github/auth/cli_spec.rb +22 -20
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/github/auth/keys_file_spec.rb +15 -1
- metadata +30 -3
- data/lib/github/auth/options.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4820a1741b347219adce20aeebf63d1082b19894
|
4
|
+
data.tar.gz: 6b28fd0ecbbbbc6fdde94fac117f28dc0683f64b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70137debed74f2596644550f765f4dfb9ea006251eda640d28a26e6664909ffcaf50923e0a00d29ec785df7413ccec2d19cc2e407d986ff28c0d13dee49c65d3
|
7
|
+
data.tar.gz: a804be8659549eb4762e58652ef34a4361124d14193558be46d1fd2af026254efafa8556091ba938d19207ffbe5bf1308742e27ee274325947dbe5e9293cd1fb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
##v3.0.0
|
4
|
+
*2013-10-24*
|
5
|
+
|
6
|
+
[\[19 commits\]](https://github.com/chrishunt/github-auth/compare/v2.0.0...v3.0.0)
|
7
|
+
|
8
|
+
*note:* CLI syntax has changed in this release as a result of switching to
|
9
|
+
[`Thor`](https://github.com/erikhuda/thor). See the
|
10
|
+
[`README`](https://github.com/chrishunt/github-auth/blob/master/README.md) for
|
11
|
+
usage instructions.
|
12
|
+
|
13
|
+
- [Use `Thor` for parsing CLI options](https://github.com/chrishunt/github-auth/pull/18)
|
14
|
+
- [Add `--command` option for custom ssh commands](https://github.com/chrishunt/github-auth/pull/18)
|
15
|
+
|
3
16
|
##v2.0.0
|
4
17
|
*2013-10-22*
|
5
18
|
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-auth (
|
4
|
+
github-auth (3.0.0)
|
5
5
|
httparty (~> 0.11.0)
|
6
|
+
thor (~> 0.18)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -11,6 +12,7 @@ GEM
|
|
11
12
|
parallel
|
12
13
|
cane-hashcheck (1.2.0)
|
13
14
|
cane
|
15
|
+
coderay (1.0.9)
|
14
16
|
colorize (0.5.8)
|
15
17
|
coveralls (0.6.7)
|
16
18
|
colorize
|
@@ -24,10 +26,15 @@ GEM
|
|
24
26
|
httparty (0.11.0)
|
25
27
|
multi_json (~> 1.0)
|
26
28
|
multi_xml (>= 0.5.2)
|
29
|
+
method_source (0.8.2)
|
27
30
|
mime-types (1.24)
|
28
31
|
multi_json (1.7.9)
|
29
32
|
multi_xml (0.5.5)
|
30
33
|
parallel (0.9.0)
|
34
|
+
pry (0.9.12.2)
|
35
|
+
coderay (~> 1.0.5)
|
36
|
+
method_source (~> 0.8)
|
37
|
+
slop (~> 3.4)
|
31
38
|
rack (1.5.2)
|
32
39
|
rack-protection (1.5.0)
|
33
40
|
rack
|
@@ -50,6 +57,7 @@ GEM
|
|
50
57
|
rack (~> 1.4)
|
51
58
|
rack-protection (~> 1.4)
|
52
59
|
tilt (~> 1.3, >= 1.3.4)
|
60
|
+
slop (3.4.6)
|
53
61
|
thin (1.5.1)
|
54
62
|
daemons (>= 1.0.9)
|
55
63
|
eventmachine (>= 0.12.6)
|
@@ -66,6 +74,7 @@ DEPENDENCIES
|
|
66
74
|
cane-hashcheck (~> 1.2.0)
|
67
75
|
coveralls (~> 0.6.7)
|
68
76
|
github-auth!
|
77
|
+
pry (~> 0.9.12)
|
69
78
|
rake (~> 10.1.0)
|
70
79
|
rspec (~> 2.14)
|
71
80
|
sinatra (~> 1.4.3)
|
data/README.md
CHANGED
@@ -23,37 +23,45 @@ After you've [installed](#installation) `gh-auth`, you can give me ssh access
|
|
23
23
|
with:
|
24
24
|
|
25
25
|
```bash
|
26
|
-
$ gh-auth
|
26
|
+
$ gh-auth add --users=chrishunt
|
27
|
+
Adding 2 key(s) to '/Users/chris/.ssh/authorized_keys'
|
28
|
+
```
|
29
|
+
|
30
|
+
If you'd like me to automatically connect to your existing tmux session, you
|
31
|
+
can do that with a custom ssh command:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ gh-auth add --users=chrishunt --command="tmux attach"
|
27
35
|
Adding 2 key(s) to '/Users/chris/.ssh/authorized_keys'
|
28
36
|
```
|
29
37
|
|
30
38
|
That was easy! When we're done working, you can revoke my access with:
|
31
39
|
|
32
40
|
```bash
|
33
|
-
$ gh-auth
|
41
|
+
$ gh-auth remove --users=chrishunt
|
34
42
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
35
43
|
```
|
36
44
|
|
37
45
|
You can add and remove any number of users at the same time.
|
38
46
|
|
39
47
|
```bash
|
40
|
-
$ gh-auth
|
48
|
+
$ gh-auth add --users=chrishunt zachmargolis
|
41
49
|
Adding 4 key(s) to '/Users/chris/.ssh/authorized_keys'
|
42
50
|
|
43
|
-
$ gh-auth
|
44
|
-
|
51
|
+
$ gh-auth list
|
52
|
+
chrishunt zachmargolis
|
45
53
|
|
46
|
-
$ gh-auth
|
54
|
+
$ gh-auth remove --users=chrishunt
|
47
55
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
48
56
|
|
49
|
-
$ gh-auth
|
50
|
-
|
57
|
+
$ gh-auth list
|
58
|
+
zachmargolis
|
51
59
|
|
52
|
-
$ gh-auth
|
60
|
+
$ gh-auth remove --users=zachmargolis
|
53
61
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
54
62
|
|
55
|
-
$ gh-auth
|
56
|
-
|
63
|
+
$ gh-auth list
|
64
|
+
|
57
65
|
```
|
58
66
|
|
59
67
|
## Sections
|
@@ -80,14 +88,42 @@ Added users:
|
|
80
88
|
|
81
89
|
`gh-auth` can be used from the command line after the gem has been installed.
|
82
90
|
|
83
|
-
```
|
84
|
-
|
91
|
+
```
|
92
|
+
$ gh-auth
|
93
|
+
Commands:
|
94
|
+
gh-auth add --users=one two three # Add GitHub users to authorized keys
|
95
|
+
gh-auth help [COMMAND] # Describe available commands or one specific command
|
96
|
+
gh-auth list # List all GitHub users already added to authorized keys
|
97
|
+
gh-auth remove --users=one two three # Remove GitHub users from authorized keys
|
98
|
+
gh-auth version # Show gh-auth version
|
99
|
+
|
100
|
+
Options:
|
101
|
+
[--host=HOST]
|
102
|
+
[--path=PATH]
|
103
|
+
```
|
85
104
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
105
|
+
Use the `help` command for help on a specific command.
|
106
|
+
|
107
|
+
```
|
108
|
+
$ gh-auth help add
|
109
|
+
Usage:
|
110
|
+
gh-auth add --users=one two three
|
111
|
+
|
112
|
+
Options:
|
113
|
+
--users=one two three
|
114
|
+
[--command=COMMAND]
|
115
|
+
[--host=HOST]
|
116
|
+
[--path=PATH]
|
117
|
+
|
118
|
+
Description:
|
119
|
+
`gh-auth add` is used to add one or more GitHub user's public SSH keys to ~/.ssh/authorized_keys. All keys stored on github.com for that user will be added.
|
120
|
+
|
121
|
+
> $ gh-auth add --users=chrishunt zachmargolis
|
122
|
+
> Adding 6 key(s) to '/Users/chris/.ssh/authorized_keys'
|
123
|
+
|
124
|
+
By default, users will be granted normal shell access. If you'd like to specify an ssh command that should execute when the user connects, use the `--command` option.
|
125
|
+
|
126
|
+
> $ gh-auth add --users=chrishunt --command="tmux attach"
|
91
127
|
```
|
92
128
|
|
93
129
|
### In Your Project
|
@@ -99,10 +135,10 @@ too.
|
|
99
135
|
require 'github/auth'
|
100
136
|
|
101
137
|
# Add keys for GitHub user 'chrishunt'
|
102
|
-
Github::Auth::CLI.
|
138
|
+
Github::Auth::CLI.start %w(add --users=chrishunt)
|
103
139
|
|
104
140
|
# Remove keys for GitHub user 'chrishunt'
|
105
|
-
Github::Auth::CLI.
|
141
|
+
Github::Auth::CLI.start %w(remove --users=chrishunt)
|
106
142
|
```
|
107
143
|
|
108
144
|
## Installation
|
@@ -111,15 +147,6 @@ Install the `github-auth` gem:
|
|
111
147
|
|
112
148
|
```bash
|
113
149
|
$ gem install github-auth
|
114
|
-
|
115
|
-
$ gh-auth
|
116
|
-
usage: gh-auth [--version] [--list] [--add|--remove] <username>
|
117
|
-
|
118
|
-
options:
|
119
|
-
--add doug,sally Add GitHub users
|
120
|
-
--remove doug,sally Remove GitHub users
|
121
|
-
--list List all GitHub users added
|
122
|
-
--version Show version
|
123
150
|
```
|
124
151
|
|
125
152
|
### SSH Public Key Authentication (Mac OS X)
|
@@ -147,7 +174,7 @@ First, authorize yourself for ssh. (Make sure to replace 'chrishunt' with
|
|
147
174
|
*your* GitHub username)
|
148
175
|
|
149
176
|
```bash
|
150
|
-
$ gh-auth
|
177
|
+
$ gh-auth add --users=chrishunt
|
151
178
|
Adding 2 key(s) to '/Users/chris/.ssh/authorized_keys'
|
152
179
|
```
|
153
180
|
|
@@ -163,7 +190,7 @@ $ ssh -o PreferredAuthentications=publickey localhost
|
|
163
190
|
Next, remove your public keys from the keys file:
|
164
191
|
|
165
192
|
```bash
|
166
|
-
$ gh-auth
|
193
|
+
$ gh-auth remove --users=chrishunt
|
167
194
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
168
195
|
```
|
169
196
|
|
data/bin/gh-auth
CHANGED
data/github-auth.gemspec
CHANGED
@@ -24,8 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'coveralls', '~> 0.6.7'
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.1.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.9.12'
|
27
28
|
spec.add_development_dependency 'sinatra', '~> 1.4.3'
|
28
29
|
spec.add_development_dependency 'thin', '~> 1.5.1'
|
29
30
|
|
30
31
|
spec.add_runtime_dependency 'httparty', '~> 0.11.0'
|
32
|
+
spec.add_runtime_dependency 'thor', '~> 0.18'
|
31
33
|
end
|
data/lib/github/auth.rb
CHANGED
data/lib/github/auth/cli.rb
CHANGED
@@ -1,40 +1,77 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
1
3
|
module Github::Auth
|
2
4
|
# Command Line Interface for parsing and executing commands
|
3
|
-
class CLI
|
4
|
-
|
5
|
+
class CLI < Thor
|
6
|
+
class_option :host, type: :string
|
7
|
+
class_option :path, type: :string
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
option :users, type: :array, required: true
|
10
|
+
option :command, type: :string
|
11
|
+
desc 'add', 'Add GitHub users to authorized keys'
|
12
|
+
long_desc <<-LONGDESC
|
13
|
+
`gh-auth add` is used to add one or more GitHub user's public SSH keys
|
14
|
+
to ~/.ssh/authorized_keys. All keys stored on github.com for that
|
15
|
+
user will be added.
|
10
16
|
|
11
|
-
|
17
|
+
> $ gh-auth add --users=chrishunt zachmargolis
|
18
|
+
\x5> Adding 6 key(s) to '/Users/chris/.ssh/authorized_keys'
|
12
19
|
|
20
|
+
By default, users will be granted normal shell access. If you'd like to
|
21
|
+
specify an ssh command that should execute when the user connects, use
|
22
|
+
the `--command` option.
|
23
|
+
|
24
|
+
> $ gh-auth add --users=chrishunt --command="tmux attach"
|
25
|
+
LONGDESC
|
13
26
|
def add
|
14
27
|
on_keys_file :write!,
|
15
|
-
"Adding #{keys.count} key(s) to '#{keys_file.path}'"
|
28
|
+
"Adding #{keys.count} key(s) to '#{keys_file.path}'",
|
29
|
+
{ command: options[:command] }
|
16
30
|
end
|
17
31
|
|
32
|
+
option :users, type: :array, required: true
|
33
|
+
desc 'remove', 'Remove GitHub users from authorized keys'
|
34
|
+
long_desc <<-LONGDESC
|
35
|
+
`gh-auth remove` is used to remove one or more GitHub user's public SSH
|
36
|
+
keys from ~/.ssh/authorized_keys. All keys stored on github.com for
|
37
|
+
that user will be removed.
|
38
|
+
|
39
|
+
> $ gh-auth remove --users=chrishunt zachmargolis
|
40
|
+
\x5> Removing 6 key(s) to '/Users/chris/.ssh/authorized_keys'
|
41
|
+
LONGDESC
|
18
42
|
def remove
|
19
43
|
on_keys_file :delete!,
|
20
44
|
"Removing #{keys.count} key(s) from '#{keys_file.path}'"
|
21
45
|
end
|
22
46
|
|
47
|
+
desc 'list', 'List all GitHub users already added to authorized keys'
|
48
|
+
long_desc <<-LONGDESC
|
49
|
+
`gh-auth list` will list all GitHub users that have been added to
|
50
|
+
~/.ssh/authorized_keys by `gh-auth`.
|
51
|
+
|
52
|
+
> $ gh-auth list
|
53
|
+
\x5> chrishunt, zachmargolis
|
54
|
+
LONGDESC
|
23
55
|
def list
|
24
|
-
puts
|
56
|
+
puts keys_file.github_users.join(' ')
|
25
57
|
end
|
26
58
|
|
59
|
+
desc 'version', 'Show gh-auth version'
|
27
60
|
def version
|
28
61
|
puts Github::Auth::VERSION
|
29
62
|
end
|
30
63
|
|
31
|
-
|
32
|
-
|
64
|
+
private
|
65
|
+
|
66
|
+
def keys
|
67
|
+
@keys ||= begin
|
68
|
+
Array(options[:users]).map { |user| keys_for user }.flatten.compact
|
69
|
+
end
|
33
70
|
end
|
34
71
|
|
35
|
-
def on_keys_file(action, message)
|
72
|
+
def on_keys_file(action, message, options = {})
|
36
73
|
puts message
|
37
|
-
rescue_keys_file_errors { keys_file.send action, keys }
|
74
|
+
rescue_keys_file_errors { keys_file(options).send action, keys }
|
38
75
|
end
|
39
76
|
|
40
77
|
def rescue_keys_file_errors
|
@@ -51,10 +88,6 @@ module Github::Auth
|
|
51
88
|
puts " $ touch #{keys_file.path}"
|
52
89
|
end
|
53
90
|
|
54
|
-
def keys
|
55
|
-
@keys ||= options.usernames.map { |user| keys_for user }.flatten.compact
|
56
|
-
end
|
57
|
-
|
58
91
|
def keys_for(username)
|
59
92
|
Github::Auth::KeysClient.new(
|
60
93
|
hostname: github_hostname,
|
@@ -68,16 +101,17 @@ module Github::Auth
|
|
68
101
|
puts "https://status.github.com"
|
69
102
|
end
|
70
103
|
|
71
|
-
def keys_file
|
72
|
-
Github::Auth::KeysFile.new
|
104
|
+
def keys_file(options = {})
|
105
|
+
Github::Auth::KeysFile.new \
|
106
|
+
options.merge path: keys_file_path
|
73
107
|
end
|
74
108
|
|
75
109
|
def keys_file_path
|
76
|
-
Github::Auth::KeysFile::DEFAULT_PATH
|
110
|
+
options[:path] || Github::Auth::KeysFile::DEFAULT_PATH
|
77
111
|
end
|
78
112
|
|
79
113
|
def github_hostname
|
80
|
-
Github::Auth::KeysClient::DEFAULT_HOSTNAME
|
114
|
+
options[:host] || Github::Auth::KeysClient::DEFAULT_HOSTNAME
|
81
115
|
end
|
82
116
|
end
|
83
117
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Github::Auth
|
2
2
|
# Write and delete keys from the authorized_keys file
|
3
3
|
class KeysFile
|
4
|
-
attr_reader :path
|
4
|
+
attr_reader :path, :command
|
5
5
|
|
6
6
|
PermissionDeniedError = Class.new StandardError
|
7
7
|
FileDoesNotExistError = Class.new StandardError
|
@@ -10,6 +10,7 @@ module Github::Auth
|
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@path = File.expand_path(options[:path] || DEFAULT_PATH)
|
13
|
+
@command = options[:command]
|
13
14
|
end
|
14
15
|
|
15
16
|
def write!(keys)
|
@@ -19,7 +20,7 @@ module Github::Auth
|
|
19
20
|
unless keys_file_content.empty? || keys_file_content.end_with?("\n")
|
20
21
|
keys_file.write "\n"
|
21
22
|
end
|
22
|
-
keys_file.write "#{key}\n"
|
23
|
+
keys_file.write "#{"command=\"#{command}\" " if command}#{key}\n"
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -62,7 +63,7 @@ module Github::Auth
|
|
62
63
|
def keys_file_content_without(keys)
|
63
64
|
keys_file_content.tap do |content|
|
64
65
|
Array(keys).each do |key|
|
65
|
-
content.gsub!
|
66
|
+
content.gsub! /(.*)?#{Regexp.escape key.key}(.*)?$\n?/, ''
|
66
67
|
end
|
67
68
|
|
68
69
|
content << "\n" unless content.empty? || content.end_with?("\n")
|
data/lib/github/auth/version.rb
CHANGED
@@ -11,23 +11,22 @@ describe Github::Auth::CLI do
|
|
11
11
|
|
12
12
|
after { keys_file.unlink }
|
13
13
|
|
14
|
-
def cli
|
15
|
-
described_class.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
14
|
+
def cli(args = [])
|
15
|
+
described_class.start \
|
16
|
+
args + [
|
17
|
+
"--path=#{keys_file.path}",
|
18
|
+
"--host=#{hostname}"
|
19
|
+
]
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'adds and removes keys from the keys file' do
|
24
|
-
cli
|
23
|
+
cli %w(add --users=chrishunt)
|
25
24
|
|
26
25
|
keys_file.read.tap do |keys_file_content|
|
27
26
|
keys.each { |key| expect(keys_file_content).to include key.to_s }
|
28
27
|
end
|
29
28
|
|
30
|
-
cli
|
29
|
+
cli %w(remove --users=chrishunt)
|
31
30
|
|
32
31
|
expect(keys_file.read).to be_empty
|
33
32
|
|
@@ -35,29 +34,32 @@ describe Github::Auth::CLI do
|
|
35
34
|
end
|
36
35
|
|
37
36
|
it 'lists users from the keys file' do
|
38
|
-
cli
|
37
|
+
cli %w(add --users=chrishunt)
|
39
38
|
|
40
39
|
output = capture_stdout do
|
41
|
-
cli
|
40
|
+
cli %w(list)
|
42
41
|
end
|
43
42
|
|
44
43
|
expect(output).to include('chrishunt')
|
45
44
|
end
|
46
45
|
|
46
|
+
it 'supports ssh commands' do
|
47
|
+
cli %w(add --users=chrishunt) << '--command=tmux attach'
|
48
|
+
|
49
|
+
expect(keys_file.read).to include 'command="tmux attach"'
|
50
|
+
|
51
|
+
keys_file.rewind
|
52
|
+
cli %w(remove --users=chrishunt)
|
53
|
+
|
54
|
+
expect(keys_file.read.strip).to be_empty
|
55
|
+
end
|
56
|
+
|
47
57
|
it 'prints version information' do
|
48
58
|
output = capture_stdout do
|
49
|
-
cli
|
59
|
+
cli %w(version)
|
50
60
|
end
|
51
61
|
|
52
62
|
expect(output).to include Github::Auth::VERSION
|
53
63
|
end
|
54
|
-
|
55
|
-
it 'prints usage for invalid arguments' do
|
56
|
-
[[], %w(invalid), %w(--add)].each do |invalid_arguments|
|
57
|
-
expect(
|
58
|
-
capture_stdout { cli.execute invalid_arguments }
|
59
|
-
).to include 'usage: gh-auth'
|
60
|
-
end
|
61
|
-
end
|
62
64
|
end
|
63
65
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,9 +4,10 @@ require 'github/auth/key'
|
|
4
4
|
require 'github/auth/keys_file'
|
5
5
|
|
6
6
|
describe Github::Auth::KeysFile do
|
7
|
-
subject { described_class.new
|
7
|
+
subject { described_class.new(options) }
|
8
8
|
|
9
9
|
let(:keys_file) { Tempfile.new 'authorized_keys' }
|
10
|
+
let(:options) {{ path: path }}
|
10
11
|
let(:path) { keys_file.path }
|
11
12
|
|
12
13
|
after { keys_file.unlink } # clean up, delete tempfile
|
@@ -78,6 +79,19 @@ describe Github::Auth::KeysFile do
|
|
78
79
|
it_should_behave_like 'a successful key addition'
|
79
80
|
end
|
80
81
|
|
82
|
+
context 'with an ssh command' do
|
83
|
+
let(:options) {{ path: path, command: 'tmux attach' }}
|
84
|
+
let(:keys) {[ Github::Auth::Key.new('chris', 'abc123') ]}
|
85
|
+
|
86
|
+
it_should_behave_like 'a successful key addition'
|
87
|
+
|
88
|
+
it 'prefixes the key with the ssh command' do
|
89
|
+
subject.write! keys
|
90
|
+
|
91
|
+
expect(keys_file.read).to include 'command="tmux attach"'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
81
95
|
context 'with existing keys in the keys file' do
|
82
96
|
let(:existing_keys) { %w(abc123 def456 ghi789) }
|
83
97
|
let(:keys) {[ Github::Auth::Key.new('chris', 'jkl012') ]}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.14'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.12
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.12
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sinatra
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,20 @@ dependencies:
|
|
136
150
|
- - ~>
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: 0.11.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: thor
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ~>
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.18'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ~>
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.18'
|
139
167
|
description: SSH key management for Github users
|
140
168
|
email:
|
141
169
|
- c@chrishunt.co
|
@@ -161,7 +189,6 @@ files:
|
|
161
189
|
- lib/github/auth/key.rb
|
162
190
|
- lib/github/auth/keys_client.rb
|
163
191
|
- lib/github/auth/keys_file.rb
|
164
|
-
- lib/github/auth/options.rb
|
165
192
|
- lib/github/auth/version.rb
|
166
193
|
- spec/acceptance/github/auth/cli_spec.rb
|
167
194
|
- spec/acceptance/github/auth/keys_client_spec.rb
|
data/lib/github/auth/options.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
module Github::Auth
|
4
|
-
# Parses command line options
|
5
|
-
class Options
|
6
|
-
attr_reader :parser
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@parser = OptionParser.new do |opts|
|
10
|
-
opts.banner = [
|
11
|
-
'usage: gh-auth',
|
12
|
-
'[--version]',
|
13
|
-
'[--list]',
|
14
|
-
'[--add|--remove]',
|
15
|
-
'<username>'
|
16
|
-
].join(' ')
|
17
|
-
|
18
|
-
opts.separator "\noptions:"
|
19
|
-
|
20
|
-
opts.on(
|
21
|
-
'--add doug,sally', Array, 'Add GitHub users'
|
22
|
-
) do |usernames|
|
23
|
-
raise OptionParser::MissingArgument if usernames.empty?
|
24
|
-
@command = 'add'
|
25
|
-
@usernames = usernames
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on(
|
29
|
-
'--remove doug,sally', Array, 'Remove GitHub users'
|
30
|
-
) do |usernames|
|
31
|
-
raise OptionParser::MissingArgument if usernames.empty?
|
32
|
-
@command = 'remove'
|
33
|
-
@usernames = usernames
|
34
|
-
end
|
35
|
-
|
36
|
-
opts.on('--list', 'List all GitHub users added') do
|
37
|
-
@command = 'list'
|
38
|
-
end
|
39
|
-
|
40
|
-
opts.on('--version', 'Show version') do
|
41
|
-
@command = 'version'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def command
|
47
|
-
@command ||= 'usage'
|
48
|
-
end
|
49
|
-
|
50
|
-
def usernames
|
51
|
-
@usernames ||= []
|
52
|
-
end
|
53
|
-
|
54
|
-
def usage
|
55
|
-
parser.help
|
56
|
-
end
|
57
|
-
|
58
|
-
def parse(args)
|
59
|
-
parser.parse(args)
|
60
|
-
ensure
|
61
|
-
return self
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|