From 451e7fac0b7cb6c7cb3659c8a4acceaab6125123 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 4 Aug 2011 14:27:01 +0100 Subject: Added pop3 server. --HG-- rename : lib/mauve/auth_bytemark.rb => lib/mauve/authentication.rb --- lib/mauve/web_interface.rb | 50 +++------------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) (limited to 'lib/mauve/web_interface.rb') 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 -- cgit v1.2.1