class NononoSender::Http::App

Public Instance Methods

authorized?() click to toggle source
# File lib/nonono_sender/http.rb, line 23
def authorized?
  @auth ||=  Rack::Auth::Basic::Request.new(request.env)
  @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [ENV['NONONO_HTTP_USER'], ENV['NONONO_HTTP_PASSWORD']]
end
protected!() click to toggle source
# File lib/nonono_sender/http.rb, line 16
def protected!
  unless authorized?
    response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
    throw(:halt, [401, "Not authorized\n"])
  end
end