module OkComputer

Private: Storage of the checks which have been registered with OkComputer.

No one is expected to interact directly with this class, but rather through the outer OkComputer interface.

Constants

VERSION

Attributes

analytics_ignore[RW]

Public: Option to disable third-party app performance tools (.e.g NewRelic) from counting OkComputer routes towards their total.

check_in_parallel[RW]

Public: whether to execute checks in parallel.

logger[RW]

Public: Logger to use to log check results

mount_at[RW]

Public: The route to automatically mount the OkComputer engine. Setting to false prevents OkComputer from automatically mounting itself.

options[RW]

Private: The options container

password[RW]

Private: The password for access to checks

username[RW]

Private: The username for access to checks

Public Class Methods

authenticate(username_try, password_try) click to toggle source

Public: Attempt to authenticate against required username and password

username - Username to authenticate with password - Password to authenticate with

Returns a Boolean

# File lib/ok_computer/configuration.rb, line 28
def self.authenticate(username_try, password_try)
  return true unless requires_authentication?

  username == username_try && password == password_try
end
make_optional(checks) click to toggle source

Public: Mark listed checks as optional

# File lib/ok_computer/configuration.rb, line 44
def self.make_optional(checks)
  checks.each do |check|
    OkComputer::Registry.register check, OkComputer::OptionalCheck.new(OkComputer::Registry.fetch(check))
  end
end
require_authentication(username, password, options = {}) click to toggle source

Public: Configure HTTP Basic authentication

username - Username required to view checks password - Password required to view checks options - Hash of additional options

- except - Array of checks to skip authentication for

Examples:

OkComputer.require_authentication("foo", "bar")
# => Require authentication with foo:bar for all checks

OkComputer.require_authentication("foo", "bar", except: %w(default nonsecret))
# => Require authentication with foo:bar for all checks except the checks named "default" and "nonsecret"
# File lib/ok_computer/configuration.rb, line 16
def self.require_authentication(username, password, options = {})
  self.username = username
  self.password = password
  self.options = options
end
requires_authentication?(params={}) click to toggle source

Public: Whether OkComputer is configured to require authentication

Returns a Boolean

# File lib/ok_computer/configuration.rb, line 37
def self.requires_authentication?(params={})
  return false if params[:action] == "show" && whitelist.include?(params[:check])

  username && password
end
whitelist() click to toggle source

Private: Configure a whitelist of checks to skip authentication

# File lib/ok_computer/configuration.rb, line 74
def whitelist
  options.fetch(:except) { [] }
end