2 #**************************************************************************
3 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
5 # This program is free software; you can redistribute it and/or modify *
6 # it under the terms of the GNU General Public License as published by *
7 # the Free Software Foundation; either version 2 of the License, or *
8 # (at your option) any later version. *
10 # This program is distributed in the hope that it will be useful, *
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 # GNU General Public License for more details. *
15 # You should have received a copy of the GNU General Public License *
16 # along with this program; if not, write to the *
17 # Free Software Foundation, Inc., *
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 #**************************************************************************/
21 package ND::Web::AuthHandler;
23 use warnings FATAL => 'all';
26 use Apache2::Access ();
30 my($res, $sent_pw) = $r->get_basic_auth_pw;
31 return $res if $res != Apache2::Const::OK;
33 my $dbh = ND::DB::DB();
34 my ($count) = $dbh->selectrow_array(q{SELECT count(*) FROM users WHERE
35 lower(username) = lower(?) AND password = MD5(?)},undef,$r->user,$sent_pw);
38 return Apache2::Const::OK;
40 $r->note_basic_auth_failure();
41 return Apache2::Const::AUTH_REQUIRED;