~ubuntu-branches/debian/sid/bugzilla/sid

« back to all changes in this revision

Viewing changes to Bugzilla/Auth/Verify/DB.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Patrick Davies
  • Date: 2008-05-29 17:20:32 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080529172032-tddh964ztksxayjm
Tags: 3.0.4-0ubuntu1
* New upstream release (LP: #138886, #235701).
* Removed "CVS" directories and ".cvsignore" files from upstream tarball.
* Added patches/ubuntu_01_bugzilla_libpath.dpatch - newly updated as necessary
  version of old 01_libpath.dpatch patch.
* Added patches/01_debian_package_version.dpatch - replaces old patch
  01_VERSION.dpatch, simply changes the version of Bugzilla to show the
  Debian packaging's versioning.
* Added patches/ubuntu_05_makefile_install.dpatch - Use a Makefile to
  install Bugzilla to the correct locations. Based on Makefile in old
  package but in patch form.
* Removed 02_checksetup.dpatch - fixed upstream.
* Removed 101_Config.diff - upstream has changed codebase.
* Renamed 06_contrib.dpatch to ubuntu_02_contrib_shebang_fixes.dpatch -
  corrects 'shebangs' which point to /usr/local/bin/ to /usr/bin/.
* Renamed 08_showdependencygraph.dpatch to
  ubuntu_03_showdependencygraph_url_fixes.dpatch and updated code as
  necessary - fixes graph URL to make the webdot generation possible.
* Removed CVE-2007-0791.dpatch - applied to upstream code.
* Removed CVE-2007-4543.dpatch - applied to upstream code.
* Renamed 09_homelink.dpatch to ubuntu_04_fixed_homepage_linked.dpatch -
  upstream now has links in
  'template/en/default/global/common-links.html.tmpl' instead of
  'useful-links.html.tmpl'.
* Removed 03_webpath.dpatch - upstream has changed stylesheet layout.
* Updated 10_perl_scripts_shebang.dpatch and removed part on "globals.pl" -
  no longer in source.
* Removed Debian vhost support patches (see docs/html/multiple-bz-dbs.html
  for how to run multiple Bugzilla instances):
  - Removed 04_Config.pm.dpatch - duplicate patch and unable to adapt it to
    new upstream code.
  - Removed 07_virtualhosting.dpatch - duplicate patch of
    04_Config.pm.dpatch.
  - Removed 'debian/examples' - contained Apache VHost example setup files
    for Bugzilla.
  - Removed section about vhosts from README.Debian.
* debian/rules:
  - Removed rules for "vhost conf dir", "examples" and "101_Config.diff"
    installation rules.
  - Removed part about bugzilla-fr package.
  - Remved part about "whine.pl" - now in Makefile.
  - Added rules to check the setup with upstream's "checksetup.pl" script.
* debian/control:
  - Updated Standards-Version to 3.7.3.
  - Updated compatibity level and debhelper build dependency version to 6.
  - Added Homepage field to source package stanza.
  - Added part about seeing 'bugzilla' package for more info to
    'bugzilla-docs'.
  - Added libapache2-mod-perl2, libtemplate-perl, libmime-perl,
    libappconfig-perl, libdbd-mysql-perl, libtimedate-perl, libgd-gd2-perl,
    libgd-text-perl, libxml-twig-perl, perlmagick, libemail-send-perl,
    libemail-mime-modifier-perl, libchart-perl, libgd-graph-perl,
    libhtml-scrubber-perl, libdbi-perl, libfile-spec-perl, libgd-graph-perl,
    libgd-text-perl, libnet-ldap-perl, libxml-parser-perl: to build
    dependencies with the necessary versions as stated by upstream in
    docs/html/installation.html - in order to check packaging correctly with
    'checksetup.pl' in rules. Also updated the 'bugzilla' dependencies with
    the above (LP: #235461).
  - Removed dependencies on old "apache" packages as they are no longer in
    the archives.
  - Moved mail transport agents on 'bugzilla' from Depends to
    Suggests (LP: #156405).
* debian/copyright: Updated the downloaded from link.
* debian/bugzilla.docs: Added "QUICKSTART", "rel_notes.txt" and "UPGRADING"
  documentation from source tarball for inclusion in package.
* debian/bugzilla-doc.doc-base: Corrected some spelling mistakes.
* debian/bugzilla.postinst: Removed sections about 101_Config.diff.
* Changed 'X_BUGZILLA_SITE' in bugzilla.cron.daily and bugzilla.postinst to
  'PROJECT'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#                 Erik Stambaugh <erik@dasbistro.com>
29
29
 
30
30
package Bugzilla::Auth::Verify::DB;
31
 
 
32
31
use strict;
 
32
use base qw(Bugzilla::Auth::Verify);
33
33
 
34
 
use Bugzilla::Config;
35
34
use Bugzilla::Constants;
 
35
use Bugzilla::Token;
36
36
use Bugzilla::Util;
37
37
use Bugzilla::User;
38
38
 
39
 
my $edit_options = {
40
 
    'new' => 1,
41
 
    'userid' => 0,
42
 
    'login_name' => 1,
43
 
    'realname' => 1,
44
 
};
45
 
 
46
 
sub can_edit {
47
 
    my ($class, $type) = @_;
48
 
    return $edit_options->{$type};
49
 
}
50
 
 
51
 
sub authenticate {
52
 
    my ($class, $username, $passwd) = @_;
53
 
 
54
 
    return (AUTH_NODATA) unless defined $username && defined $passwd;
55
 
 
56
 
    my $userid = Bugzilla::User::login_to_id($username);
57
 
    return (AUTH_LOGINFAILED) unless $userid;
58
 
 
59
 
    return (AUTH_LOGINFAILED, $userid) 
60
 
        unless $class->check_password($userid, $passwd);
 
39
sub check_credentials {
 
40
    my ($self, $login_data) = @_;
 
41
    my $dbh = Bugzilla->dbh;
 
42
 
 
43
    my $username = $login_data->{username};
 
44
    my $user_id  = login_to_id($username);
 
45
 
 
46
    return { failure => AUTH_NO_SUCH_USER } unless $user_id;
 
47
 
 
48
    $login_data->{bz_username} = $username;
 
49
    my $password = $login_data->{password};
 
50
 
 
51
    trick_taint($username);
 
52
    my ($real_password_crypted) = $dbh->selectrow_array(
 
53
        "SELECT cryptpassword FROM profiles WHERE userid = ?",
 
54
        undef, $user_id);
 
55
 
 
56
    # Using the internal crypted password as the salt,
 
57
    # crypt the password the user entered.
 
58
    my $entered_password_crypted = crypt($password, $real_password_crypted);
 
59
 
 
60
    return { failure => AUTH_LOGINFAILED }
 
61
        if $entered_password_crypted ne $real_password_crypted;
61
62
 
62
63
    # The user's credentials are okay, so delete any outstanding
63
64
    # password tokens they may have generated.
64
 
    require Bugzilla::Token;
65
 
    Bugzilla::Token::DeletePasswordTokens($userid, "user_logged_in");
66
 
 
67
 
    # Account may have been disabled
68
 
    my $disabledtext = $class->get_disabled($userid);
69
 
    return (AUTH_DISABLED, $userid, $disabledtext)
70
 
      if $disabledtext ne '';
71
 
 
72
 
    return (AUTH_OK, $userid);
73
 
}
74
 
 
75
 
sub get_disabled {
76
 
    my ($class, $userid) = @_;
77
 
    my $dbh = Bugzilla->dbh;
78
 
    my $sth = $dbh->prepare_cached("SELECT disabledtext FROM profiles " .
79
 
                                   "WHERE userid=?");
80
 
    my ($text) = $dbh->selectrow_array($sth, undef, $userid);
81
 
    return $text;
82
 
}
83
 
 
84
 
sub check_password {
85
 
    my ($class, $userid, $passwd) = @_;
86
 
    my $dbh = Bugzilla->dbh;
87
 
    my $sth = $dbh->prepare_cached("SELECT cryptpassword FROM profiles " .
88
 
                                   "WHERE userid=?");
89
 
    my ($realcryptpwd) = $dbh->selectrow_array($sth, undef, $userid);
90
 
 
91
 
    # Get the salt from the user's crypted password.
92
 
    my $salt = $realcryptpwd;
93
 
 
94
 
    # Using the salt, crypt the password the user entered.
95
 
    my $enteredCryptedPassword = crypt($passwd, $salt);
96
 
 
97
 
    return $enteredCryptedPassword eq $realcryptpwd;
 
65
    Bugzilla::Token::DeletePasswordTokens($user_id, "user_logged_in");
 
66
 
 
67
    return $login_data;
98
68
}
99
69
 
100
70
sub change_password {
101
 
    my ($class, $userid, $password) = @_;
 
71
    my ($self, $user, $password) = @_;
102
72
    my $dbh = Bugzilla->dbh;
103
73
    my $cryptpassword = bz_crypt($password);
104
 
    $dbh->do("UPDATE profiles SET cryptpassword = ? WHERE userid = ?", 
105
 
             undef, $cryptpassword, $userid);
 
74
    $dbh->do("UPDATE profiles SET cryptpassword = ? WHERE userid = ?",
 
75
             undef, $cryptpassword, $user->id);
106
76
}
107
77
 
108
78
1;
109
 
 
110
 
__END__
111
 
 
112
 
=head1 NAME
113
 
 
114
 
Bugzilla::Auth::Verify::DB - database authentication for Bugzilla
115
 
 
116
 
=head1 SUMMARY
117
 
 
118
 
This is an L<authentication module|Bugzilla::Auth/"AUTHENTICATION"> for
119
 
Bugzilla, which logs the user in using the password stored in the C<profiles>
120
 
table. This is the most commonly used authentication module.
121
 
 
122
 
=head1 SEE ALSO
123
 
 
124
 
L<Bugzilla::Auth>