okcomputer 0.3.8 → 0.4.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.
@@ -39,7 +39,7 @@ private
39
39
  end
40
40
 
41
41
  def authenticate
42
- if OKComputer.requires_authentication?
42
+ if OKComputer.requires_authentication?(params)
43
43
  authenticate_or_request_with_http_basic do |username, password|
44
44
  OKComputer.authenticate(username, password)
45
45
  end
@@ -3,9 +3,20 @@ module OKComputer
3
3
  #
4
4
  # username - Username required to view checks
5
5
  # password - Password required to view checks
6
- def self.require_authentication(username, password)
6
+ # options - Hash of additional options
7
+ # - except - Array of checks to skip authentication for
8
+ #
9
+ # Examples:
10
+ #
11
+ # OKComputer.require_authentication("foo", "bar")
12
+ # # => Require authentication with foo:bar for all checks
13
+ #
14
+ # OKComputer.require_authentication("foo", "bar", except: %w(default nonsecret))
15
+ # # => Require authentication with foo:bar for all checks except the checks named "default" and "nonsecret"
16
+ def self.require_authentication(username, password, options = {})
7
17
  self.username = username
8
18
  self.password = password
19
+ self.options = options
9
20
  end
10
21
 
11
22
  # Public: Attempt to authenticate against required username and password
@@ -23,7 +34,9 @@ module OKComputer
23
34
  # Public: Whether OKComputer is configured to require authentication
24
35
  #
25
36
  # Returns a Boolean
26
- def self.requires_authentication?
37
+ def self.requires_authentication?(params={})
38
+ return false if params[:action] == "show" && whitelist.include?(params[:check])
39
+
27
40
  username && password
28
41
  end
29
42
 
@@ -52,4 +65,14 @@ module OKComputer
52
65
  @password = password
53
66
  end
54
67
  private_class_method :password=
68
+
69
+ # Private: Set, you know, options
70
+ def self.options=(options)
71
+ @options = options
72
+ end
73
+
74
+ # Private: Configure a whitelist of checks to skip authentication
75
+ def self.whitelist
76
+ @options.fetch(:except) { [] }
77
+ end
55
78
  end
@@ -1,3 +1,3 @@
1
1
  module OKComputer
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okcomputer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Patrick Byrne
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,49 +30,55 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: sqlite3
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec-rails
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: coveralls
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
- description: "\n Inspired by the simplicity of Fitter Happier, but frustrated by
70
- its lack of\n flexibility, we built OK Computer. Create and register your own
71
- custom\n health checks, or choose from the built-in library of checks to ensure
72
- your\n app is working as intended.\n "
78
+ description: ! "\n Inspired by the simplicity of Fitter Happier, but frustrated
79
+ by its lack of\n flexibility, we built OK Computer. Create and register your
80
+ own custom\n health checks, or choose from the built-in library of checks to
81
+ ensure your\n app is working as intended.\n "
73
82
  email:
74
83
  - patrick.byrne@tstmedia.com
75
84
  executables: []
@@ -98,25 +107,32 @@ files:
98
107
  - README.markdown
99
108
  homepage: https://github.com/sportngin/okcomputer
100
109
  licenses: []
101
- metadata: {}
102
110
  post_install_message:
103
111
  rdoc_options: []
104
112
  require_paths:
105
113
  - lib
106
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
107
116
  requirements:
108
- - - '>='
117
+ - - ! '>='
109
118
  - !ruby/object:Gem::Version
110
119
  version: '0'
120
+ segments:
121
+ - 0
122
+ hash: -2759090005785899265
111
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
112
125
  requirements:
113
- - - '>='
126
+ - - ! '>='
114
127
  - !ruby/object:Gem::Version
115
128
  version: '0'
129
+ segments:
130
+ - 0
131
+ hash: -2759090005785899265
116
132
  requirements: []
117
133
  rubyforge_project:
118
- rubygems_version: 2.0.3
134
+ rubygems_version: 1.8.25
119
135
  signing_key:
120
- specification_version: 4
136
+ specification_version: 3
121
137
  summary: A simple, extensible health-check monitor
122
138
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c8d8aac1c2611f9746defd5c71d1e68819cf336c
4
- data.tar.gz: 24ffab3e54db81700bbf2f6aa4931c3ceee39829
5
- SHA512:
6
- metadata.gz: 102901ac0514c9716d1bf3f4fc6dea90f7c5749ca477b826af61e076a4cba71179c277f73cd7500652d5bb64fe03b49a5612b5485c7d522219f280df76bf3c80
7
- data.tar.gz: 4c537aad26c2494a2cea8dd79c3e2cf205f6a081a433b5a132ba6a4f6f0d02f6279d612f90f93daf564a4ffea37388f9f164cd0761d26e2bfa499edb45ffeecd