diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-04 14:27:52 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-04 14:27:52 +0100 |
commit | 02a177d8e744f7e084bc69d10a0b7f8fb7e3bd44 (patch) | |
tree | ba46705bc35bc3b8f0e01ac05bd6879e2c9d448e /lib/mauve/web_interface.rb | |
parent | 10141ed04af966ee280dcea1d733e0b036127afc (diff) | |
parent | 451e7fac0b7cb6c7cb3659c8a4acceaab6125123 (diff) |
merge
Diffstat (limited to 'lib/mauve/web_interface.rb')
-rw-r--r-- | lib/mauve/web_interface.rb | 50 |
1 files changed, 3 insertions, 47 deletions
diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb index 9369ee3..805a3e3 100644 --- a/lib/mauve/web_interface.rb +++ b/lib/mauve/web_interface.rb @@ -3,6 +3,8 @@ require 'haml' require 'redcloth' require 'json' +require 'mauve/authentication' + require 'sinatra/tilt' require 'sinatra/base' require 'sinatra-partials' @@ -148,7 +150,7 @@ EOF # next_page = '/' if next_page == '/logout' - if auth_helper(usr, pwd) + if Authentication.authenticate(usr, pwd) session['username'] = usr redirect next_page else @@ -463,52 +465,6 @@ EOF list[@cycle] end - ## Test for authentication with SSO. - # - def auth_helper (usr, pwd) - # First try Bytemark - # - auth = AuthBytemark.new() - result = begin - auth.authenticate(usr,pwd) - rescue Exception => ex - logger.error "Caught exception during Bytemark auth for #{usr} (#{ex.to_s})" - logger.debug ex.backtrace.join("\n") - false - end - - if true == result - return true - else - logger.warn "Bytemark authentication failed for #{usr}" - end - - # - # OK now try local auth - # - result = begin - if Configuration.current.people.has_key?(usr) - Digest::SHA1.hexdigest(params['password']) == Configuration.current.people[usr].password - end - rescue Exception => ex - logger.error "Caught exception during local auth for #{usr} (#{ex.to_s})" - logger.debug ex.backtrace.join("\n") - false - end - - if true == result - return true - else - logger.warn "Local authentication failed for #{usr}" - end - - # - # Rate limit logins. - # - sleep 5 - false - end - end error DataMapper::ObjectNotFoundError do |