lib/sensu/api/http_handler.rb
def authorized?
        api = @settings[:api]
        if api && api[:user] && api[:password]
          if @http_request_method == OPTIONS_METHOD
            true
          elsif @http[:authorization]
            scheme, base64 = @http[:authorization].split("\s")
            if scheme == "Basic"
              user, password = Base64.decode64(base64).split(":")
              user == api[:user] && password == api[:password]
            else
              false
            end
          else
            false
          end
        else
          true
        end
      end
# Determine if an HTTP request is authorized. This method
# compares the configured API user and password (if any) with
# the HTTP request basic authentication credentials. No
# authentication is done if the API user and password are not
# configured. OPTIONS HTTP requests bypass authentication.
#
# @return [TrueClass, FalseClass]
Determine if an HTTP request is authorized. This method
compares the configured API user and password (if any) with
the HTTP request basic authentication credentials. No
authentication is done if the API user and password are not
configured. OPTIONS HTTP requests bypass authentication.
Determine if an HTTP request is authorized . This method compares the configured API user and password ( if any ) with the HTTP request basic authentication credentials . No authentication is done if the API user and password are not configured . OPTIONS HTTP requests bypass authentication .
def authorized?
        api = @settings[:api]
        if api && api[:user] && api[:password]
          if @http_request_method == OPTIONS_METHOD
            true
          elsif @http[:authorization]
            scheme, base64 = @http[:authorization].split("\s")
            if scheme == "Basic"
              user, password = Base64.decode64(base64).split(":")
              user == api[:user] && password == api[:password]
            else
              false
            end
          else
            false
          end
        else
          true
        end
      end
def authorized? api = @settings [ :api ] if api && api [ :user ] && api [ :password ] if @http_request_method == OPTIONS_METHOD true elsif @http [ :authorization ] scheme , base64 = @http [ :authorization ] . split ( "\s" ) if scheme == "Basic" user , password = Base64 . decode64 ( base64 ) . split ( ":" ) user == api [ :user ] && password == api [ :password ] else false end else false end else true end end
Determine if an HTTP request is authorized.
Determine if an HTTP request is authorized .
None
TrueClass, FalseClass