class Fluent::BasicAuthHttp

Public Instance Methods

on_request(path_info, params) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_basic_auth_http.rb, line 5
def on_request(path_info, params)
  unless authenticate(params["HTTP_AUTHORIZATION"])
    return ['401 Unauthorized', {'Content-type'=>'text/plain'}, "401 Unauthorized\n"]
  end

  super
end

Private Instance Methods

authenticate(value) click to toggle source
# File lib/fluent/plugin/in_basic_auth_http.rb, line 15
def authenticate(value)
  return false unless value
  require 'base64'
  base64_str = value.split(' ', 2).last || ''
  Base64.decode64(base64_str) == "#{ENV['USERNAME']}:#{ENV['PASSWORD']}"
end