require File.expand_path('../setup', __FILE__) module Example class MultiScopeApp < BaseApp enable :inline_templates GITHUB_CONFIG = { :client_id => ENV['GITHUB_CLIENT_ID'] || 'test_client_id', :client_secret => ENV['GITHUB_CLIENT_SECRET'] || 'test_client_secret' } use Warden::Manager do |config| config.failure_app = BadAuthentication config.default_strategies :github config.scope_defaults :default, :config => GITHUB_CONFIG config.scope_defaults :admin, :config => GITHUB_CONFIG.merge(:scope => 'user,notifications') end get '/' do erb :index end get '/login' do env['warden'].authenticate! redirect '/' end get '/admin/login' do env['warden'].authenticate!(:scope => :admin) redirect '/' end get '/logout' do if params.include?('all') env['warden'].logout else env['warden'].logout(:default) end redirect '/' end get '/admin/logout' do env['warden'].logout(:admin) redirect '/' end end def self.app @app ||= Rack::Builder.new do run MultiScopeApp end end end __END__ @@ index