Passphrase.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 31 / 31 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Passphrase/Hashed.pm ↑ Summary
1 package Dancer2::Plugin::Passphrase;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Dancer2::Plugin::Passphrase::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use Dancer2::Plugin::Passphrase::Hashed;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Dancer2::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 our $VERSION = '3.4.1';
10  
11 11 plugin_keywords 'passphrase';
12  
13 # ABSTRACT: Passphrases and Passwords as objects for Dancer2
14  
15 =head1 NAME
16  
17 Dancer2::Plugin::Passphrase - Passphrases and Passwords as objects for Dancer2
18  
19 =head1 DEPRECATION WARNING
20  
21 B<NOTE:> This module is DEPRECATED, and it is advised that you switch
22 to L<Dancer2::Plugin::CryptPassphrase> if possible.
23  
24 =head1 SYNOPSIS
25  
26 This plugin manages the hashing of passwords for Dancer2 apps, allowing
27 developers to follow cryptography best practices without having to
28 become a cryptography expert.
29  
30 It uses the bcrypt algorithm as the default, while also supporting any
31 hashing function provided by L<Digest>.
32  
33 =head1 USAGE
34  
35 package MyWebService;
36 use Dancer2;
37 use Dancer2::Plugin::Passphrase;
38  
39 post '/login' => sub {
40 my $phrase = passphrase( param('my password') )->generate;
41  
42 # $phrase is now an object that contains RFC 2307 representation
43 # of the hashed passphrase, along with the salt, and other metadata
44
45 # You should store $phrase->rfc2307() for use later
46 };
47  
48 get '/protected' => sub {
49 # Retrieve $stored_rfc_2307_string, like we created above.
50 # IT MUST be a valid RFC 2307 string
51  
52 if ( passphrase( param('my password') )->matches( $stored_rfc_2307 ) ) {
53 # Passphrase matches!
54 }
55 };
56  
57 get '/generate_new_password' => sub {
58 return passphrase->generate_random;
59 };
60  
61 =head1 NOTE
62  
63 This package does no checking about how secure the password is,
64 minimum length or anything, including a length of 0 being valid.
65 You can add extra checks in your "MyWebService".
66  
67 =head1 AUTO STRINGIFICATION IS REMOVED
68  
69 You must use $phrase->rfc2307() to get a text string.
70  
71 =head1 KEYWORDS
72  
73 =head2 passphrase
74  
75 Given a plaintext password, it returns a Dancer2::Plugin::Passphrase::Core
76 object that you can generate a new hash from, or match against a stored hash.
77  
78 =cut
79  
80 has algorithm => (
81 is => 'ro',
82 9 ▶ from_config => sub { 'Bcrypt' },
Subroutine __ANON__: called CC=1 SCAR=0.0
83 11 );
84  
85 98 ▶sub passphrase {
Subroutine passphrase: called CC=1 SCAR=0.0
Pod documented
86 98 my ($plugin, $plaintext) = @_;
87  
88 return Dancer2::Plugin::Passphrase::Core->new(
89 98 %{$plugin->config},
90 algorithm => $plugin->algorithm,
91 plaintext => $plaintext,
92 );
93 }
94  
95 11 1;
96  
97 __END__
« Passphrase/Hashed.pm ↑ Summary