wreis / DBIx-Class-EncodedColumn

Automatically encode columns
https://metacpan.org/module/DBIx::Class::EncodedColumn
Other
2 stars 7 forks source link

Allow encoding arguments to be a hashref to allow upgrading #17

Open robrwo opened 1 year ago

robrwo commented 1 year ago

Algorithms that are considered safe to use now may not be considered safe in the future. Or one often has legacy code using an algorithm that is no longer considered safe to use.

It would be nice if this could be configured to handle multiple encoding types, to allow upgrading or changing an algorithm.

The hashed password would have an optional prefix, e.g. "blowfish:fa846084d81c4cf52a5421ad351d63efe495". The encoding configuration could be a hash where the keys are the names of the coding types (with a default assumed when hashing a new password).

The configuration could be something like

__PACKAGE__->add_columns(
  'password' => {
    data_type => 'CHAR',
    size      => 22,
    encode => {
      "md5" => {
         encode_column => 1,
         encode_class  => 'Digest',
         encode_args   => {algorithm => 'MD5', format => 'base64'},
         encode_check_method => 'check_password',
         no_key => 1, # assume this if there is no prefix
      },
     "blowfish" => {
         encode_column => 1,
         encode_class  => 'Crypt::Eksblowfish::Bcrypt',
         encode_args   => { key_nul => 0, cost => 8 },
         encode_check_method => 'check_password',
         default => 1, # use this as the default algorithm
    }
}