Skip to content

Instantly share code, notes, and snippets.

@benlovell
Created November 10, 2012 12:01
Show Gist options
  • Save benlovell/4050875 to your computer and use it in GitHub Desktop.
Save benlovell/4050875 to your computer and use it in GitHub Desktop.
Sinatra auth
require 'rubygems'
require 'sinatra'
class Protected < Sinatra::Base
use Rack::Auth::Basic, "Protected Area" do |username, password|
self.authenticate username, password
end
get '/' do
"secret"
end
def self.authenticate(username, password)
username == 'foo' && password == 'bar'
end
run! if app_file == $0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment