http://www.perlmonks.org?node_id=1223799

akuk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks,

I am working on a Project to migrate the Legacy App in Perl to Catalyst Framework. Legacy app has its own authentication mechanism. And it uses Crypt::PBKDF2 to store the password in the database.

I want to use Catalyst::Plugin::Authentication instead of custom login mechanism for catalyst but I didn't find a way to authenticate password using Authentication Plugin

Legacy:

$pbk_crypt = Crypt::PBKDF2->new( hash_class => 'HMACSHA2', hash_args => { sha_size => 512, }, iterations => 10000, salt_len => 10, ); $pass = $pbk_crypt->generate('password');

Catalyst

__PACKAGE__->config( 'Plugin::Authentication' => { default => { class => 'SimpleDB', user_model => 'DB::User', password_type => 'self_check', }, )
And in the User table following code is added:
__PACKAGE__->add_columns( 'password' => { passphrase => 'rfc2307', passphrase_class => 'SaltedDigest', passphrase_args => { algorithm => 'SHA-512', salt_random => 10, iterations => 10000, }, passphrase_check_method => 'check_password', }, );

And in Controller :

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."); } }
but it's not working. I am not sure what I am doing wrong here.