DBIx::Class::SaltedPasswords - Salts password columns


DBIx-Class-SaltedPasswords documentation  | view source Contained in the DBIx-Class-SaltedPasswords distribution.

Index


NAME

Top

DBIx::Class::SaltedPasswords - Salts password columns

SYNOPSIS

Top

  __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

Top

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

Top

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

Top

The following methods are new:-

verify_password

returns 1 if the password is right, 0 else.

EXTENDED METHODS

Top

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

insert
update

SEE ALSO

Top

DBIx::Class DBIx::Class::DigestColumns

AUTHOR

Top

Moritz Onken (perler)

COPYRIGHT AND LICENSE

Top


DBIx-Class-SaltedPasswords documentation  | view source Contained in the DBIx-Class-SaltedPasswords distribution.