I know, I know! There are already some implementations out there. Please don’t
ask me why … I just did it!
Just let me put my stuff to all the other projects, ok? Now it’s up to you. :)
- Sinatra Basic Authentication – Selectively Applied
You’ll find similar DIY implementations in many sinatra projects (e.g. sinatra-wiki, …)
- sbfaulkner / sinatra_authentication
Like DIY, but uses Rack::Auth in a nice helper. Easy to use for models classes.
- blindgaenger / sinatra-auth « Yep, this project!
Adds Rack::Auth as middleware and checks protected routes before dispatching to sinatra.
- maxjustus / sinatra-authentication
If you need session based authentication using DataMapper, this is for you!
- Sinatra Lighthouse [PATCH] HTTP Authentication
But actually I really hope any HTTP authentication will become an integrated part of sinatra!
Done?
sudo gem source —add http://gems.github.com sudo gem install blindgaenger-sinatra-authUse auth
to configure :basic
authorization and the realm My App
. The block
checks your creditals.
Define your routes as usual, but now you can protect
some of them.
get '/public' do
'free'
end
protect do
get '/private' do
'secret'
end
end
Done!
You can contact me via mail at blindgaenger at gmail dot com, or leave me a
message on my Github profile.