github-auth 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a80039ae01d2be44d806515ea21ee9270f9df4e6
4
- data.tar.gz: bff60b5a1c3c03a0d52d43b2e95d6ab3526262f6
3
+ metadata.gz: 352463830e9bd640ff3d636b5ee5053b0be27518
4
+ data.tar.gz: 9f2ccad8abf686958c2c0a49b99bf838b271ffc2
5
5
  SHA512:
6
- metadata.gz: 71a7d658f2ce80eef39916981c7c9e6011e73d4cf4b2d036dffd500ba8c05ffbb0f74d3748c999d95864ef5954205633319562bc063fcb23783ac38525a2f4e9
7
- data.tar.gz: ee721cd67304276cd695cb3939b362fb1ae887dd96f4fa938ace3ca3f684a41a4e32b1f08b8ad286ed3848d445cc7e32161323626cd84ba43d6beab66cc00e9b
6
+ metadata.gz: 059b81934b81695ba445ba47427c6058c6a1c9e4d185ef7de8674df0c104820544e3d9d100899a7d738bd867cebbaaced781faff952e8c0c15aed3ed2d1b97fa
7
+ data.tar.gz: ac44f88144f64084e91f1ef74c69bf1ba8e731bd821063583f5886516910740576f0242f628d505db4ab6b3bd6a02bdba94401acdd1491414094a9b91ed078c9
data/CHANGELOG.md ADDED
@@ -0,0 +1,82 @@
1
+ # Changelog
2
+
3
+ ##v1.1.0
4
+ *2013-05-29*
5
+
6
+ [\[13 commits\]](https://github.com/chrishunt/github-auth/compare/v1.0.0...v1.1.0)
7
+
8
+ - Add link to user's GitHub profile as comment on SSH keys
9
+ - Add VPN/tunneling solutions to README
10
+ - Add CHANGELOG
11
+
12
+ ##v1.0.0
13
+ *2013-05-18*
14
+
15
+ [\[2 commits\]](https://github.com/chrishunt/github-auth/compare/v0.6.1...v1.0.0)
16
+
17
+ Nobody is complaining about bugs, so we're ready to call it **v1.0.0**
18
+
19
+ ##v0.6.1
20
+ *2013-05-10*
21
+
22
+ [\[7 commits\]](https://github.com/chrishunt/github-auth/compare/v0.6.0...v0.6.1)
23
+
24
+ - Add License information to README
25
+
26
+ ##v0.6.0
27
+ *2013-05-09*
28
+
29
+ [\[6 commits\]](https://github.com/chrishunt/github-auth/compare/v0.5.0...v0.6.0)
30
+
31
+ - Only insert blank line if inserting a key
32
+ - Don't leave blank lines when writing keys
33
+
34
+ ##v0.5.0
35
+ *2013-05-08*
36
+
37
+ [\[13 commits\]](https://github.com/chrishunt/github-auth/compare/v0.4.1...v0.5.0)
38
+
39
+ - Remove line break as well when deleting keys
40
+ - Enforce Ruby 1.9 hash syntax with Cane
41
+ - Move contributing instructions to separate doc
42
+
43
+ ##v0.4.1
44
+ *2013-04-28*
45
+
46
+ [\[15 commits\]](https://github.com/chrishunt/github-auth/compare/v0.4.0...v0.4.1)
47
+
48
+ - Check code quality by default when running specs
49
+ - Add cane as development dependency
50
+
51
+ ##v0.4.0
52
+ *2013-04-25*
53
+
54
+ [\[3 commits\]](https://github.com/chrishunt/github-auth/compare/v0.3.0...v0.4.0)
55
+
56
+ - Add `--version` option to command line client
57
+
58
+ ##v0.3.0
59
+ *2013-04-25*
60
+
61
+ [\[5 commits\]](https://github.com/chrishunt/github-auth/compare/v0.2.0...v0.3.0)
62
+
63
+ - Send github-auth user agent to GitHub when making requests
64
+
65
+ ##v0.2.0
66
+ *2013-04-22*
67
+
68
+ [\[8 commits\]](https://github.com/chrishunt/github-auth/compare/v0.1.1...v0.2.0)
69
+
70
+ - Correctly remove keys with comments in keys file
71
+
72
+ ##v0.1.1
73
+ *2013-04-15*
74
+
75
+ [\[6 commits\]](https://github.com/chrishunt/github-auth/compare/v0.1.0...v0.1.1)
76
+
77
+ - Adjustments to README
78
+
79
+ ##v0.1.0
80
+ *2013-04-15*
81
+
82
+ Initial release
data/README.md CHANGED
@@ -47,6 +47,24 @@ $ gh-auth remove zachmargolis
47
47
  Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
48
48
  ```
49
49
 
50
+ ## Sections
51
+
52
+ 1. [Usage](#usage)
53
+ - [Command Line](#command-line)
54
+ - [In Your Project](#in-your-project)
55
+ 1. [Installation](#installation)
56
+ - [SSH Public Key Authentication](#ssh-public-key-authentication-mac-os-x)
57
+ - [Verification](#verification)
58
+ 1. [Troubleshooting](#troubleshooting)
59
+ - [How do people actually connect to my machine?](#how-do-people-actually-connect-to-my-machine)
60
+ - [What username do I use?](#what-username-do-i-use)
61
+ - [How do I get my external IP?](#how-do-i-get-my-external-ip)
62
+ - [It's still not working!](#its-still-not-working-)
63
+ - [I can't enable port forwarding](#i-cant-enable-port-forwarding-my-boss-wont-let-me-can-i-still-pair)
64
+ 1. [Contributing](#contributing)
65
+ 1. [Changelog](#changelog)
66
+ 1. [License](#license)
67
+
50
68
  ## Usage
51
69
 
52
70
  ### Command Line
@@ -57,7 +75,7 @@ Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
57
75
  usage: gh-auth [--version] [add|remove] <username>
58
76
  ```
59
77
 
60
- ### In You Project
78
+ ### In Your Project
61
79
 
62
80
  Want to add/remove keys in your project, but not on the command line? That's ok
63
81
  too.
@@ -199,12 +217,19 @@ ability to forward ports. Maybe this machine is at home, a friend's house, or
199
217
  at a company your worked for in the past that forgot to turn it off.
200
218
 
201
219
  If this isn't possible, then you can use a VPS provider like
202
- [Linode](http://www.linode.com) to setup a pairing machine in the cloud.
220
+ [Linode](http://www.linode.com) to setup a pairing machine in the cloud or a
221
+ tunneling solution like [PageKite](https://pagekite.net) or
222
+ [Hamachi](https://secure.logmein.com/products/hamachi) to make your machine
223
+ accessible without forwarding ports.
203
224
 
204
225
  ## Contributing
205
226
  Please see the [Contributing
206
227
  Document](https://github.com/chrishunt/github-auth/blob/master/CONTRIBUTING.md)
207
228
 
229
+ ## Changelog
230
+ Please see the [Changelog
231
+ Document](https://github.com/chrishunt/github-auth/blob/master/CHANGELOG.md)
232
+
208
233
  ## License
209
234
  Copyright (C) 2013 Chris Hunt, [MIT
210
235
  License](https://github.com/chrishunt/github-auth/blob/master/LICENSE.txt)
data/lib/github/auth.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'github/auth/version'
2
+ require 'github/auth/key'
2
3
  require 'github/auth/keys_client'
3
4
  require 'github/auth/keys_file'
4
5
  require 'github/auth/cli'
@@ -0,0 +1,16 @@
1
+ module Github::Auth
2
+ # Represents a username/key pair from GitHub
3
+ Key = Struct.new(:username, :key) do
4
+ def to_a
5
+ [self]
6
+ end
7
+
8
+ def to_s
9
+ "#{key} #{url}"
10
+ end
11
+
12
+ def url
13
+ "https://github.com/#{username}"
14
+ end
15
+ end
16
+ end
@@ -26,7 +26,9 @@ module Github::Auth
26
26
  end
27
27
 
28
28
  def keys
29
- @keys ||= Array(github_response).map { |entry| entry.fetch 'key' }
29
+ @keys ||= Array(github_response).map do |entry|
30
+ Github::Auth::Key.new username, entry.fetch('key')
31
+ end
30
32
  end
31
33
 
32
34
  private
@@ -14,7 +14,7 @@ module Github::Auth
14
14
 
15
15
  def write!(keys)
16
16
  Array(keys).each do |key|
17
- unless keys_file_content.include? key
17
+ unless keys_file_content.include? key.key
18
18
  append_keys_file do |keys_file|
19
19
  keys_file.write "\n" unless keys_file_content.empty?
20
20
  keys_file.write key
@@ -53,7 +53,10 @@ module Github::Auth
53
53
 
54
54
  def keys_file_content_without(keys)
55
55
  keys_file_content.tap do |content|
56
- Array(keys).each {|k| content.gsub! /#{Regexp.escape k}( .*)?$\n?/, '' }
56
+ Array(keys).each do |key|
57
+ content.gsub! /#{Regexp.escape key.key}( .*)?$\n?/, ''
58
+ end
59
+
57
60
  content.strip!
58
61
  end
59
62
  end
@@ -1,5 +1,5 @@
1
1
  module Github
2
2
  module Auth
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -22,8 +22,8 @@ describe Github::Auth::CLI do
22
22
  it 'adds and removes keys from the keys file' do
23
23
  cli(%w(add chrishunt)).execute
24
24
 
25
- keys_file.read.tap do |content|
26
- keys.each { |key| expect(content).to include key }
25
+ keys_file.read.tap do |keys_file_content|
26
+ keys.each { |key| expect(keys_file_content).to include key.to_s }
27
27
  end
28
28
 
29
29
  cli(%w(remove chrishunt)).execute
@@ -6,7 +6,11 @@ describe Github::Auth::KeysFile do
6
6
  it 'writes and deletes keys from the keys file' do
7
7
  tempfile = Tempfile.new 'authorized_keys'
8
8
  keys_file = described_class.new path: tempfile.path
9
- keys = %w(abc123 def456)
9
+
10
+ keys = [
11
+ Github::Auth::Key.new('chris', 'abc123'),
12
+ Github::Auth::Key.new('doug', 'def456')
13
+ ]
10
14
 
11
15
  keys_file.write! keys
12
16
  expect(tempfile.read).to include keys.join("\n")
@@ -15,8 +19,8 @@ describe Github::Auth::KeysFile do
15
19
 
16
20
  keys_file.delete! keys.first
17
21
  tempfile.read.tap do |tempfile_content|
18
- expect(tempfile_content).to_not include keys.first
19
- expect(tempfile_content).to include keys.last
22
+ expect(tempfile_content).to_not include keys.first.to_s
23
+ expect(tempfile_content).to include keys.last.to_s
20
24
  end
21
25
 
22
26
  tempfile.rewind
@@ -2,9 +2,14 @@ require 'httparty'
2
2
  require 'sinatra/base'
3
3
  require 'json'
4
4
 
5
+ require 'github/auth/key'
6
+
5
7
  module Github::Auth
6
8
  class MockGithubServer < Sinatra::Base
7
- KEYS = %w(abc234 def456)
9
+ KEYS = [
10
+ Github::Auth::Key.new('chrishunt', 'abc123'),
11
+ Github::Auth::Key.new('chrishunt', 'def456')
12
+ ]
8
13
 
9
14
  set :port, 8001
10
15
 
@@ -16,8 +21,8 @@ module Github::Auth
16
21
  content_type :json
17
22
 
18
23
  [
19
- { 'id' => 123, 'key' => KEYS[0] },
20
- { 'id' => 456, 'key' => KEYS[1] }
24
+ { 'id' => 123, 'key' => KEYS[0].key },
25
+ { 'id' => 456, 'key' => KEYS[1].key }
21
26
  ].to_json
22
27
  end
23
28
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'github/auth/key'
2
3
  require 'github/auth/keys_client'
3
4
 
4
5
  describe Github::Auth::KeysClient do
@@ -50,12 +51,15 @@ describe Github::Auth::KeysClient do
50
51
 
51
52
  context 'when the github user has keys' do
52
53
  let(:parsed_response) {[
53
- { 'id' => 123, 'key' => 'BLAHBLAH' },
54
- { 'id' => 456, 'key' => 'FLARBBLU' }
54
+ { 'id' => 123, 'key' => 'abc123' },
55
+ { 'id' => 456, 'key' => 'def456' }
55
56
  ]}
56
57
 
57
58
  it 'returns the keys' do
58
- expected_keys = parsed_response.map { |entry| entry.fetch 'key' }
59
+ expected_keys = parsed_response.map do |entry|
60
+ Github::Auth::Key.new username, entry.fetch('key')
61
+ end
62
+
59
63
  expect(subject.keys).to eq expected_keys
60
64
  end
61
65
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'tempfile'
3
+ require 'github/auth/key'
3
4
  require 'github/auth/keys_file'
4
5
 
5
6
  describe Github::Auth::KeysFile do
@@ -38,11 +39,13 @@ describe Github::Auth::KeysFile do
38
39
 
39
40
  describe '#write!' do
40
41
  shared_examples_for 'a successful key addition' do
41
- it 'writes the key to the keys file' do
42
+ it 'writes the key and github url to the keys file' do
42
43
  subject.write! keys
43
44
 
44
45
  keys_file.read.tap do |keys_file_content|
45
- keys.each { |key| expect(keys_file_content).to include key }
46
+ keys.each do |key|
47
+ expect(keys_file_content).to include "#{key.key} #{key.url}"
48
+ end
46
49
  end
47
50
  end
48
51
 
@@ -56,20 +59,24 @@ describe Github::Auth::KeysFile do
56
59
  end
57
60
 
58
61
  context 'with many keys' do
59
- let(:keys) { %w(abc123 def456 ghi789) }
62
+ let(:keys) {[
63
+ Github::Auth::Key.new('chris', 'abc123'),
64
+ Github::Auth::Key.new('chris', 'def456'),
65
+ Github::Auth::Key.new('doug', 'ghi789')
66
+ ]}
60
67
 
61
68
  it_should_behave_like 'a successful key addition'
62
69
  end
63
70
 
64
71
  context 'with a single key' do
65
- let(:keys) { %w(abc123) }
72
+ let(:keys) {[ Github::Auth::Key.new('chris', 'abc123') ]}
66
73
 
67
74
  it_should_behave_like 'a successful key addition'
68
75
  end
69
76
 
70
77
  context 'with existing keys in the keys file' do
71
78
  let(:existing_keys) { %w(abc123 def456 ghi789) }
72
- let(:keys) { %w(jkl012) }
79
+ let(:keys) {[ Github::Auth::Key.new('chris', 'jkl012') ]}
73
80
 
74
81
  before do
75
82
  keys_file.write existing_keys.join("\n")
@@ -89,7 +96,7 @@ describe Github::Auth::KeysFile do
89
96
  end
90
97
 
91
98
  it 'does not write duplicate keys into the keys file' do
92
- subject.write! existing_keys.first
99
+ subject.write! Github::Auth::Key.new('chris', existing_keys.first)
93
100
 
94
101
  expect(keys_file.readlines.count).to eq existing_keys.count
95
102
  end
@@ -100,7 +107,7 @@ describe Github::Auth::KeysFile do
100
107
 
101
108
  it 'raises PermissionDeniedError' do
102
109
  expect {
103
- subject.write! %w(abc123 def456)
110
+ subject.write! Github::Auth::Key.new('chris', 'abc123')
104
111
  }.to raise_error Github::Auth::KeysFile::PermissionDeniedError
105
112
  end
106
113
  end
@@ -117,7 +124,11 @@ describe Github::Auth::KeysFile do
117
124
  end
118
125
 
119
126
  describe '#delete!' do
120
- let(:keys) { %w(abc123 def456 ghi789) }
127
+ let(:keys) {[
128
+ Github::Auth::Key.new('chris', 'abc123'),
129
+ Github::Auth::Key.new('chris', 'def456'),
130
+ Github::Auth::Key.new('doug', 'ghi789')
131
+ ]}
121
132
 
122
133
  before do
123
134
  keys_file.write keys.join("\n")
@@ -128,15 +139,15 @@ describe Github::Auth::KeysFile do
128
139
  it 'removes the key from the keys file' do
129
140
  subject.delete! key
130
141
 
131
- expect(keys_file.read).to_not include key
142
+ expect(keys_file.read).to_not include key.to_s
132
143
  end
133
144
 
134
145
  it 'does not remove the other keys from the keys file' do
135
146
  subject.delete! key
136
147
 
137
148
  keys_file.read.tap do |keys_file_content|
138
- keys.reject { |other_key| other_key =~ /#{key}/ }.each do |key|
139
- expect(keys_file_content).to include key
149
+ keys.reject { |other_key| other_key == key }.each do |key|
150
+ expect(keys_file_content).to include key.to_s
140
151
  end
141
152
  end
142
153
  end
@@ -168,22 +179,8 @@ describe Github::Auth::KeysFile do
168
179
  it_should_behave_like 'a successful key removal'
169
180
  end
170
181
 
171
- context 'when the key has a comment' do
172
- let(:keys) {[ 'abc123', "#{key} #{comment}", 'ghi789' ]}
173
- let(:key) { 'def456' }
174
- let(:comment) { 'this is a comment' }
175
-
176
- it_should_behave_like 'a successful key removal'
177
-
178
- it 'removes the comment from the keys file' do
179
- subject.delete! key
180
-
181
- expect(keys_file.read).to_not include comment
182
- end
183
- end
184
-
185
182
  context 'when the keys file does not have the key' do
186
- let(:key) { 'not-in-the-keys-file' }
183
+ let(:key) { Github::Auth::Key.new('sallie', 'not-in-the-keys-file') }
187
184
 
188
185
  it 'does not modify the keys file' do
189
186
  keys_file.read.tap do |original_keys_file_content|
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: 1.0.0
4
+ version: 1.1.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-05-19 00:00:00.000000000 Z
11
+ date: 2013-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,6 +146,7 @@ extra_rdoc_files: []
146
146
  files:
147
147
  - .gitignore
148
148
  - .travis.yml
149
+ - CHANGELOG.md
149
150
  - CONTRIBUTING.md
150
151
  - Gemfile
151
152
  - LICENSE.txt
@@ -156,6 +157,7 @@ files:
156
157
  - img/mac-os-ssh-sharing.jpg
157
158
  - lib/github/auth.rb
158
159
  - lib/github/auth/cli.rb
160
+ - lib/github/auth/key.rb
159
161
  - lib/github/auth/keys_client.rb
160
162
  - lib/github/auth/keys_file.rb
161
163
  - lib/github/auth/version.rb