travis 1.6.17.travis.588.5 → 1.6.17.travis.589.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmIzMzljYjljZDVjMTlkZWFmZWE0Y2FmODgzMGYxNTdjYTY0MDQ1MQ==
4
+ NWI2MjQ5MDBmNmZlZTQ1OTlkODQxMjNmYTZlZmUxZTIxZTc2MDgzNw==
5
5
  data.tar.gz: !binary |-
6
- MWU3NmE0OWE5NDIzMmM5NzI4N2Y4MWJhMmFiNzZlODkzODU0ZDIxZg==
6
+ ZmJkYTgzNzQ0MTA5YmJmODg1MTU3YjNkMzljZGZmZDk4YTAyODZlMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWUyMjBiOWM5ZjEzZjZmZTJkNWVlYjg0MzM0OTNhYzY0NmRhYjY3NjBhNWJm
10
- NmVjZTk0ZTc1NzkwMDQyNTE4ZWE3ZWE1NmE3ZWJhYjllNTdhMjEzNTIwMmVh
11
- ZDczOTRiZTUxMTVmNjQyOTA2NGMwNjI2NWNjYTZiZGFkY2ZlNDI=
9
+ NWQwODIyNGJkMWFhMDM5ZjdkYTFmYjc4MDc0OWE3OWQxYTc3NzM4YjA4MDZk
10
+ YTEzNzZmNjA0NDkwZDlkNjFiNGI5Yjc0YzVkMTMzNmI3ZDU4ZTc1MWM0NTcx
11
+ ODk5MWNiZDM2N2QzYzIyMmVkZTMyYWUzZjJmZjc1MGRlNDNjN2M=
12
12
  data.tar.gz: !binary |-
13
- OTg1ZTU2YmYwNzI0MTg1YzIzODY1NjM2ZDMyYzNkYWE0YWUzMTUxMDVjMDkw
14
- MzBiMWIxZjBhOTRlYjE0MDBjNzg5NjEyNDZiYjc0MjBmMjUzZmU1NTgyNWZj
15
- OWFkZGI2MmY3ZGUwNmU5ZDhkMzMyNmE0NGY0Nzc2OTNlYmY5NTg=
13
+ YTM5ZDA4OGM0NGQyZDZkMWJjZDZmYjQ0YmM0NzZiNzdkZDM4N2I2YzcxMmFk
14
+ YjRkMzU5ZDljNDU2ODQ5ZmNmZmIwYjZkZjlkNjUzNzU2ZWI3MjYxNjdlY2Y0
15
+ YzI4N2YxMGI5M2I2NTJiNDAyMzIwODg2N2JjNzg2ODkyYzFjYTk=
data/README.md CHANGED
@@ -1090,6 +1090,7 @@ Or a job:
1090
1090
  -u, --upload FILE upload key from given file
1091
1091
  -s, --stdin upload key read from stdin
1092
1092
  -c, --check set exit code depending on key existing
1093
+ -g, --generate generate SSH key and set up for given GitHub user
1093
1094
 
1094
1095
  *This feature is for [Pro and Enterprise](#pro-and-enterprise) only.*
1095
1096
 
@@ -1112,6 +1113,20 @@ And to remove it again:
1112
1113
  removing ssh key for travis-pro/test-project
1113
1114
  No custom SSH key installed.
1114
1115
 
1116
+ You can also have it generate a key for a given GitHub user (for instance, for a dedicated CI user that only has read access). The public key will automatically be added to GitHub and the private key to Travis CI:
1117
+
1118
+ $ travis sshkey --generate
1119
+ We need the GitHub login for the account you want to add the key to.
1120
+ This information will not be sent to Travis CI, only to api.github.com.
1121
+ The password will not be displayed.
1122
+
1123
+ Username: travisbot
1124
+ Password for travisbot: **************
1125
+
1126
+ Generating RSA key.
1127
+ Uploading public key to GitHub.
1128
+ Uploading private key to Travis CI.
1129
+
1115
1130
  #### `status`
1116
1131
 
1117
1132
  Usage: travis status [options]
@@ -1,6 +1,5 @@
1
1
  require 'travis/client'
2
- require 'openssl'
3
- require 'base64'
2
+ require 'travis/tools/ssl_key'
4
3
 
5
4
  module Travis
6
5
  module Client
@@ -17,32 +16,17 @@ module Travis
17
16
  Base64.encode64(encrypted).gsub(/\s+/, "")
18
17
  end
19
18
 
20
- def to_ssh
21
- ['ssh-rsa ', "\0\0\0\assh-rsa#{sized_bytes(to_rsa.e)}#{sized_bytes(to_rsa.n)}"].pack('a*m').gsub("\n", '')
19
+ def to_rsa
20
+ Tools::SSLKey.public_rsa_key(to_s)
22
21
  end
23
22
 
24
- def to_rsa
25
- @to_rsa ||= OpenSSL::PKey::RSA.new(to_s)
26
- rescue OpenSSL::PKey::RSAError
27
- public_key = to_s.gsub('RSA PUBLIC KEY', 'PUBLIC KEY')
28
- @to_rsa = OpenSSL::PKey::RSA.new(public_key)
23
+ def to_ssh
24
+ Tools::SSLKey.rsa_ssh(to_rsa)
29
25
  end
30
26
 
31
27
  def ==(other)
32
28
  other.to_s == self
33
29
  end
34
-
35
- private
36
-
37
- def sized_bytes(value)
38
- bytes = to_byte_array(value.to_i)
39
- [bytes.size, *bytes].pack('NC*')
40
- end
41
-
42
- def to_byte_array(num, *significant)
43
- return significant if num.between?(-1, 0) and significant[0][7] == num[7]
44
- to_byte_array(*num.divmod(256)) + significant
45
- end
46
30
  end
47
31
 
48
32
  include States
@@ -36,6 +36,14 @@ module Travis
36
36
  each_token { |t| break yield(t) }
37
37
  end
38
38
 
39
+ def with_basic_auth(&block)
40
+ user, password = ask_credentials
41
+ basic_auth(user, password, true) do |gh|
42
+ gh['user'] # so otp kicks in
43
+ yield gh
44
+ end
45
+ end
46
+
39
47
  def each_token
40
48
  require 'gh' unless defined? GH
41
49
  possible_tokens { |t| yield(t) if acceptable?(t) }
@@ -68,15 +76,20 @@ module Travis
68
76
  end
69
77
 
70
78
  if manual_login
71
- login_header.call if login_header
72
- user = github_login || ask_login.call
73
- password = ask_password.arity == 0 ? ask_password.call : ask_password.call(user)
79
+ user, password = ask_credentials
74
80
  yield login(user, password, true)
75
81
  end
76
82
 
77
83
  after_tokens.call
78
84
  end
79
85
 
86
+ def ask_credentials
87
+ login_header.call if login_header
88
+ user = github_login || ask_login.call
89
+ password = ask_password.arity == 0 ? ask_password.call : ask_password.call(user)
90
+ [user, password]
91
+ end
92
+
80
93
  def possible_logins(&block)
81
94
  netrc_logins(&block)
82
95
  hub_logins(&block)
@@ -191,22 +204,27 @@ module Travis
191
204
  api_url[%r{^(?:https?://)?([^/]+)}, 1]
192
205
  end
193
206
 
194
- def login(user, password, die = true, otp = nil)
207
+ def basic_auth(user, password, die = true, otp = nil, &block)
195
208
  opt = { :username => user, :password => password }
196
209
  opt[:headers] = { "X-GitHub-OTP" => otp } if otp
197
- gh = GH.with(opt)
198
- reply = gh.post('/authorizations', :scopes => scopes, :note => note)
199
- self.callback = proc { gh.delete reply['_links']['self']['href'] } if drop_token
200
- reply['token']
210
+ yield GH.with(opt)
201
211
  rescue GH::Error => error
202
212
  if error.info[:response_status] == 401 and error.info[:response_headers]['x-github-otp'].to_s =~ /required/
203
213
  otp = ask_otp.arity == 0 ? ask_otp.call : ask_otp.call(user)
204
- login(user, password, die, otp)
214
+ basic_auth(user, password, die, otp, &block)
205
215
  elsif die
206
216
  raise gh_error(error)
207
217
  end
208
218
  end
209
219
 
220
+ def login(user, password, die = true, otp = nil)
221
+ basic_auth(user, password, die, otp) do |gh|
222
+ reply = gh.post('/authorizations', :scopes => scopes, :note => note)
223
+ self.callback = proc { gh.delete reply['_links']['self']['href'] } if drop_token
224
+ reply['token']
225
+ end
226
+ end
227
+
210
228
  def acceptable?(token)
211
229
  return true unless check_token
212
230
  gh = GH.with(:token => token)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.17.travis.588.5
4
+ version: 1.6.17.travis.589.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -39,7 +39,7 @@ authors:
39
39
  autorequire:
40
40
  bindir: bin
41
41
  cert_chain: []
42
- date: 2014-07-23 00:00:00.000000000 Z
42
+ date: 2014-07-24 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: faraday