From: Tony Tony Date: 2009-08-06T12:18:40+09:00 Subject: How to logout when using Rake::Auth::Basic in Sinatra Hi all, Sorry for the repost - I think I have the correct forum now! I'm writting a small app that requires basic authentication in Sinatra. I followed the advice of the official Sinatra faq (http://www.sinatrarb.com/faq.html#auth) and have implemented this code with success: [code] require 'rubygems' require 'sinatra' helpers do def protected! response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth") and \ throw(:halt, [401, "Not authorized\n"]) and \ return unless authorized? end def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == ['admin', 'admin'] end end get '/' do "Everybody can see this page" end get '/protected' do protected! "Welcome, authenticated client" end [/code] So I get a window asking me to ender my credentials when going to /protected and it logs me in. Once logged in though, I would like to be able to log out. I know the solution to this must be super easy but I just can't get it to work. Any help is greatly appreciated. Thanks! -Tony -- Posted via http://www.ruby-forum.com/.