class Bosh::Registry::ApiController

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/bosh/registry/api_controller.rb, line 38
def initialize
  super
  @logger = Bosh::Registry.logger

  @users = Set.new
  @users << [Bosh::Registry.http_user, Bosh::Registry.http_password]
  @instance_manager = Bosh::Registry.instance_manager
end

Public Instance Methods

authorized?() click to toggle source
# File lib/bosh/registry/api_controller.rb, line 54
def authorized?
  @auth ||= Rack::Auth::Basic::Request.new(request.env)
  @auth.provided? &&
    @auth.basic? &&
    @auth.credentials &&
    @users.include?(@auth.credentials)
end
json(payload) click to toggle source
# File lib/bosh/registry/api_controller.rb, line 62
def json(payload)
  Yajl::Encoder.encode(payload)
end
protected!() click to toggle source
# File lib/bosh/registry/api_controller.rb, line 47
def protected!
  unless authorized?
    headers("WWW-Authenticate" => 'Basic realm="Bosh Registry"')
    halt(401, json("status" => "access_denied"))
  end
end