Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically encrypt the password column.
- Loading branch information
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use 5.010; | ||
|
||
use DBIx::Class::Schema::Loader qw[make_schema_at]; | ||
|
||
make_schema_at( | ||
'Lystyng::Schema', { | ||
dump_directory => 'lib', | ||
use_moose => 1, | ||
components => [ 'EncodedColumn' ], | ||
custom_column_info => \&encode_password, | ||
}, [ | ||
"dbi:mysql:dbname=$ENV{LYSTYNG_DB_NAME};host=$ENV{LYSTYNG_DB_SERVER}", | ||
$ENV{LYSTYNG_DB_USER}, $ENV{LYSTYNG_DB_PASS}, | ||
], | ||
); | ||
|
||
sub encode_password { | ||
my ($table, $column_name) = @_; | ||
|
||
if ($column_name eq 'password') { | ||
return { | ||
encode_column => 1, | ||
encode_class => 'Digest', | ||
encode_args => { | ||
algorithm => 'SHA-1', | ||
format => 'hex', | ||
salt_length => 10, | ||
}, | ||
encode_check_method => 'check_password', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters