skylight 0.4.0.beta1 → 0.4.0.beta2

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: b792bd9edd83c6519aa2abe19c57a5309681c1fb
4
- data.tar.gz: 6c577191b4a08ecb0d2ed68bd538ada731b5bfd7
3
+ metadata.gz: 5c2c971886aa2187432210157c789a499aa414b3
4
+ data.tar.gz: 89f8c9dd4bcca24cca6f9cb58871a223bd142bbd
5
5
  SHA512:
6
- metadata.gz: 4399d887807138ea93c8067f4845fe905f06128edc7cdda3525d488ff25390c2ed06bfecfd18dfa042ba4fdbc48dac109e62590fe63a9cf23dd928c3c0aa7363
7
- data.tar.gz: d15a4f6cff77015930eecc7afab684ba862f5272a2fd792a9edffa0ca7e450a391212ccf1247ce571ada3b1021726cd520cc4a23ef2a5ff9ad8c6543d84d4dc9
6
+ metadata.gz: 006fecbbc09d50807beecb2d46dcb21ef2f7750bc719f535cee16200e368f2caf2de8bd1074de133d7e24e44ad1e27cd960bad2cdedb0fffa511fe903e29e0ec
7
+ data.tar.gz: e6caf8cd228af8c0e61ffd134581e9f7d9639451b3050e07996ef11aacd26ccb5520190654393a1d78772a4ab2226712c227f642824a09ba89e93cc2a65d6e65
@@ -1,6 +1,6 @@
1
1
  ---
2
- version: "0.4.0-d2c73cb"
2
+ version: "0.4.0-e42cc44"
3
3
  checksums:
4
- x86-linux: "4671996cf24d012452db68a792a70c23665b6efb1454e95e4fb1544df69615c0"
5
- x86_64-linux: "51c82df086af87ea12c7aaa78c0d387ee540e93474d1df6ad8eb7db85d1841e4"
6
- x86_64-darwin: "6b06223198062cce67a8c57e26e51b6907eb09baf5e53ad3ea13b3b62366d99e"
4
+ x86-linux: "77c56fc8a34ae2b1a1f5af97ce177e59beeff5475410864af9aafbf130dab323"
5
+ x86_64-linux: "1f16effac4b96f3b214df061927cd6332a913c07b3f1d76b3c8053e9156a5732"
6
+ x86_64-darwin: "5f95596ccbd720b68b98ba012b7371c18ea674712c52d45a807620e9c5c3d127"
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Skylight
2
4
  # @api private
3
5
  class Api
@@ -40,6 +42,23 @@ module Skylight
40
42
  @http.authentication = token
41
43
  end
42
44
 
45
+ def validate_authentication
46
+ url = URI.parse(config[:auth_url])
47
+
48
+ res = @http.get(url.path)
49
+
50
+ case res.status
51
+ when 200...300
52
+ :ok
53
+ when 400...500
54
+ :invalid
55
+ else
56
+ :unknown
57
+ end
58
+ rescue
59
+ :unknown
60
+ end
61
+
43
62
  def login(email, password)
44
63
  res = http.get('/me', 'X-Email' => email, 'X-Password' => password)
45
64
 
@@ -81,7 +81,7 @@ module Skylight
81
81
  # Default values for Skylight configuration keys
82
82
  DEFAULTS = {
83
83
  :'version' => VERSION,
84
- :'auth_url' => 'https://www.skylight.io/agent/authenticate',
84
+ :'auth_url' => 'https://auth.skylight.io/agent',
85
85
  :'daemon.lazy_start' => true,
86
86
  :'daemon.ssl_cert_path' => Util::SSL.ca_cert_file_or_default,
87
87
  :'daemon.ssl_cert_dir' => Util::SSL.ca_cert_dir,
@@ -333,6 +333,9 @@ module Skylight
333
333
  end
334
334
  end
335
335
 
336
+ ret << "SKYLIGHT_VALIDATE_AUTHENTICATION"
337
+ ret << "false"
338
+
336
339
  ret
337
340
  end
338
341
 
@@ -1,5 +1,6 @@
1
1
  require 'thread'
2
2
  require 'strscan'
3
+ require 'skylight/api'
3
4
 
4
5
  module Skylight
5
6
  # @api private
@@ -107,6 +108,11 @@ module Skylight
107
108
  t { "starting instrumenter" }
108
109
  @config.validate!
109
110
 
111
+ unless validate_authentication
112
+ warn "invalid authentication token"
113
+ return
114
+ end
115
+
110
116
  t { "starting native instrumenter" }
111
117
  unless native_start
112
118
  warn "failed to start instrumenter"
@@ -251,5 +257,30 @@ module Skylight
251
257
  config.key?(:ignored_endpoint) && trace.endpoint == config[:ignored_endpoint]
252
258
  end
253
259
 
260
+ # Validates that the provided authentication token is valid. This is done
261
+ # by issuing a request for a session token and checking the response
262
+ def validate_authentication
263
+ # If a session token is specified, don't bother attempting to validate
264
+ if config[:session_token]
265
+ true
266
+ else
267
+ api = Api.new(config)
268
+ api.authentication = config[:authentication]
269
+
270
+ case res = api.validate_authentication
271
+ when :ok
272
+ true
273
+ when :invalid
274
+ false
275
+ when :unknown
276
+ warn "unable to validate authentication token"
277
+ true
278
+ else
279
+ error "[BUG] unexpected validate_token result; res=%s", res
280
+ true
281
+ end
282
+ end
283
+ end
284
+
254
285
  end
255
286
  end
@@ -13,23 +13,27 @@ module Skylight
13
13
  ENV['SKYLIGHT_LIB_PATH'] || File.expand_path("../native/#{Util::Platform.tuple}", __FILE__)
14
14
  end
15
15
 
16
+ skylight_required = ENV.key?("SKYLIGHT_REQUIRED") && ENV['SKYLIGHT_REQUIRED'] !~ /^false$/i
17
+
16
18
  begin
17
- unless ENV["SKYLIGHT_DISABLE_AGENT"]
19
+ unless ENV.key?("SKYLIGHT_DISABLE_AGENT") && ENV['SKYLIGHT_DISABLE_AGENT'] !~ /^false$/i
18
20
  lib = "#{libskylight_path}/libskylight.#{Util::Platform.libext}"
19
21
 
20
22
  if File.exist?(lib)
21
23
  # First attempt to require the native extension
22
- require 'skylight_native'
24
+ require "skylight_native"
23
25
 
24
26
  # Attempt to link the dylib
25
27
  load_libskylight(lib)
26
28
 
27
29
  # If nothing was thrown, then the native extension is present
28
30
  @@has_native_ext = true
31
+ elsif skylight_required
32
+ raise LoadError, "Cannot find native extensions in #{libskylight_path}"
29
33
  end
30
34
  end
31
35
  rescue LoadError => e
32
- raise if ENV.key?("SKYLIGHT_REQUIRED")
36
+ raise if skylight_required
33
37
  end
34
38
 
35
39
  unless Skylight.native?
@@ -7,10 +7,10 @@ module Skylight
7
7
  require 'skylight/util/hostname'
8
8
  require 'skylight/util/logging'
9
9
  require 'skylight/util/ssl'
10
+ require 'skylight/util/http'
10
11
 
11
12
  # Used from the CLI
12
13
  autoload :Gzip, 'skylight/util/gzip'
13
- autoload :HTTP, 'skylight/util/http'
14
14
  autoload :Inflector, 'skylight/util/inflector'
15
15
  end
16
16
  end
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'openssl'
4
4
  require 'net/http'
5
5
  require 'net/https'
6
+ require 'skylight/util/gzip'
6
7
  require 'skylight/util/ssl'
7
8
 
8
9
  module Skylight
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.4.0-beta1'
2
+ VERSION = '0.4.0-beta2'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.beta1
4
+ version: 0.4.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-17 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport