
DBIx::Class::SaltedPasswords - Salts password columns

__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'
);

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.

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

The following methods are new:-
returns 1 if the password is right, 0 else.

The following DBIx::Class::Row methods are extended by this module:-

DBIx::Class DBIx::Class::DigestColumns

Moritz Onken (perler)

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.