NAME
DBIx::Class::SaltedPasswords - Salts password columns
SYNOPSIS
__PACKAGE__->load_components(qw/SaltedPasswords ... Core /);
__PACKAGE__->saltedpasswords(
column => "password", # no defaul value
salt_lenght => 6, # default: 6
enabled => 1, # default: 1
salt_column =>'salt' # default: 'salt'
);
DESCRIPTION
This module generates for every insert or update of a specified column a random salt, adds it to the value and hashes the complete string with MD5. The salt is stored in the salt_column column. To verify a password against the table use the verify_password method.
EXAMPLE
In your table scheme (e.g. User):
__PACKAGE__->load_components(qw/SaltedPasswords ... Core /);
__PACKAGE__->saltedpasswords(
column => "password"
);
In your application:
sub register {
$db->resultset('User')->create(
{
name => 'Paul',
password => 'secret'
}
)->update;
}
This registers a new user with a crypted password ($password is plaintext, the encryption is done by this module). Make sure the salt column exists.
my $rs = $db->resultset('User')->search({name => 'Paul'})->first; # Or use find() and your primary key
$rs->verify_password('secret'); # returns 1 if the password is right
This validates the password
NEW METHODS
The following methods are new:-
- verify_password
-
returns 1 if the password is right, 0 else.
EXTENDED METHODS
The following DBIx::Class::Row methods are extended by this module:-
- insert
- update
SEE ALSO
DBIx::Class DBIx::Class::DigestColumns
AUTHOR
Moritz Onken (perler)
COPYRIGHT AND LICENSE
Copyright (C) 2006 by perler
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 134:
You forgot a '=back' before '=head1'
- Around line 145:
You forgot a '=back' before '=head1'