| 1 | # | ||
| 2 | #=============================================================================== | ||
| 3 | # | ||
| 4 | # FILE: PwnedError.pm | ||
| 5 | # | ||
| 6 | # DESCRIPTION: Throw an exception for failure to check pwned password | ||
| 7 | # | ||
| 8 | # FILES: --- | ||
| 9 | # BUGS: --- | ||
| 10 | # NOTES: --- | ||
| 11 | # AUTHOR: Pete Houston, cpan@openstrike.co.uk | ||
| 12 | # ORGANIZATION: Openstrike | ||
| 13 | # VERSION: See $VERSION in code | ||
| 14 | # CREATED: 18/07/18 14:53:15 | ||
| 15 | # REVISION: --- | ||
| 16 | #=============================================================================== | ||
| 17 | |||
| 18 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | package Password::Policy::Exception::PwnedError; | ||
| 22 | |||
| 23 | 4 | ▶ | use parent 'Password::Policy::Exception'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | 4 | our $VERSION = '0.03'; | |
| 26 | |||
| 27 | 3 | ▶ | sub error { return 'Invalid response checking for pwned password'; } |
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | Password::Policy::Exception::PwnedError - Die if the password pwned API is unreachable | ||
| 32 | |||
| 33 | =head1 SYNOPSIS | ||
| 34 | |||
| 35 | use Password::Policy; | ||
| 36 | use Try::Tiny; | ||
| 37 | |||
| 38 | my $pass = 'password1'; | ||
| 39 | |||
| 40 | my $pp = Password::Policy->new (config => 'policy.yaml'); | ||
| 41 | try { | ||
| 42 | $pp->process({ password => $pass }); | ||
| 43 | } catch { | ||
| 44 | warn "This password '$pass' is pwned - don't use it"; | ||
| 45 | # Other actions | ||
| 46 | } | ||
| 47 | |||
| 48 | =head1 DESCRIPTION | ||
| 49 | |||
| 50 | This exception is thrown when L<Password::Policy::Rule::Pwned> | ||
| 51 | cannot determine whether or not a password has been pwned. The | ||
| 52 | determination depends on a remote service which may not be available for | ||
| 53 | any number of reasons. | ||
| 54 | |||
| 55 | =head1 METHODS | ||
| 56 | |||
| 57 | =head2 error | ||
| 58 | |||
| 59 | $exception->error (); | ||
| 60 | |||
| 61 | This method is not expected to be called directly but rather via | ||
| 62 | C<Password::Policy-E<gt>process>. It returns the text of an appropriate | ||
| 63 | error which in this case is "Invalid response checking for pwned password". | ||
| 64 | |||
| 65 | =head1 SEE ALSO | ||
| 66 | |||
| 67 | For how to determine if passwords are pwned, see | ||
| 68 | L<Password::Policy::Rule::Pwned>. | ||
| 69 | |||
| 70 | To understand how to use this as part of a wider password policy | ||
| 71 | enforcement program, see L<Password::Policy>. | ||
| 72 | |||
| 73 | =head1 REPOSITORY | ||
| 74 | |||
| 75 | L<https://gitlab.com/openstrike/password-pwned> | ||
| 76 | |||
| 77 | =head1 MAINTAINER | ||
| 78 | |||
| 79 | This module is written and maintained by Pete Houston of Openstrike | ||
| 80 | <cpan@openstrike.co.uk> | ||
| 81 | |||
| 82 | =head1 COPYRIGHT INFORMATION | ||
| 83 | |||
| 84 | Copyright 2018 by Pete Houston. All Rights Reserved. | ||
| 85 | |||
| 86 | Permission to use, copy, and distribute is hereby granted, | ||
| 87 | providing that the above copyright notice and this permission | ||
| 88 | appear in all copies and in supporting documentation. | ||
| 89 | |||
| 90 | =head1 LICENCE | ||
| 91 | |||
| 92 | This program is free software; you can redistribute it and/or modify it | ||
| 93 | under the same terms as Perl itself. | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | 4 | 1; | |