$pbk_crypt = Crypt::PBKDF2->new(
hash_class => 'HMACSHA2',
hash_args => {
sha_size => 512,
},
iterations => 10000,
salt_len => 10,
);
$pass = $pbk_crypt->generate('password');
####
__PACKAGE__->config(
'Plugin::Authentication' => {
default => {
class => 'SimpleDB',
user_model => 'DB::User',
password_type => 'self_check',
},
)
##
##
__PACKAGE__->add_columns(
'password' => {
passphrase => 'rfc2307',
passphrase_class => 'SaltedDigest',
passphrase_args => {
algorithm => 'SHA-512',
salt_random => 10,
iterations => 10000,
},
passphrase_check_method => 'check_password',
},
);
##
##
if ($username and $password) {
if ($c->authenticate({ username => $username,
password => $password } )) {
$c->response->redirect($c->uri_for_action('/profile'));
return;
} else {
# Set an error message
$c->stash(error_msg => "Bad username or password.");
}
}