Module: Sinatra::ADAuth
- Defined in:
- lib/sinatra/ad_auth.rb,
lib/sinatra/ad_user.rb,
lib/sinatra/ad_version.rb
Defined Under Namespace
Modules: Helpers Classes: User
Constant Summary collapse
- VERSION =
"0.25.20120401"
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sinatra/ad_auth.rb', line 21 def self.registered(app) app.helpers ADAuth::Helpers app.enable :sessions app.get '/login' do "<form method='POST' action='/login'>" + "<input type='text' name='user'>" + "<input type='password' name='pass'>" + "<input type='submit'>" + "</form>" end # Public - This API authenticates an user against a given Active # Directory server # app.post '/login' do user = Sinatra::ADAuth::User.authenticate(params[:user],params[:pass], settings.conf) if ! user.nil? session[:authorized] = true puts "here we are #{session[:authorized]}" redirect '/public' else session[:authorized] = false redirect '/login' end end end |