Created
November 10, 2012 12:01
-
-
Save benlovell/4050875 to your computer and use it in GitHub Desktop.
Sinatra auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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