| 1 | # | ||||||||||
| 2 | # Apache::Auth::User::Basic | ||||||||||
| 3 | # An Apache basic authentication user class. | ||||||||||
| 4 | # | ||||||||||
| 5 | # (C) 2003-2007 Julian Mehnle <julian@mehnle.net> | ||||||||||
| 6 | # $Id: Basic.pm 31 2007-09-18 01:39:14Z julian $ | ||||||||||
| 7 | # | ||||||||||
| 8 | ############################################################################## | ||||||||||
| 9 | |||||||||||
| 10 | package Apache::Auth::User::Basic; | ||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use version; our $VERSION = qv('0.120'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use base qw(Apache::Auth::User); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | # Constants: | ||||||||||
| 22 | ############################################################################## | ||||||||||
| 23 | |||||||||||
| 24 | 2 | ▶ | use constant TRUE => (0 == 0); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | ▶ | use constant FALSE => not TRUE; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | use constant crypt_salt_characters => ('.', '/', '0'..'9', 'A'..'Z', 'a'..'z'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | # Interface: | ||||||||||
| 30 | ############################################################################## | ||||||||||
| 31 | |||||||||||
| 32 | sub signature; | ||||||||||
| 33 | sub password; | ||||||||||
| 34 | |||||||||||
| 35 | # Implementation: | ||||||||||
| 36 | ############################################################################## | ||||||||||
| 37 | |||||||||||
| 38 | 6 | ▶ | sub signature { | ||||||||
|
Subroutine
signature: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 39 | 6 | my ($self) = @_; | |||||||||
| 40 | 6 | return $self->name; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub password { | ||||||||
|
Subroutine
password: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 44 | 0 | my ($self, @value) = @_; | |||||||||
| 45 | 0 | ▶ | if (@value) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | $self->{password} = $value[0]; | |||||||||
| 47 | $self->{password_digest} = $self->_build_password_digest | ||||||||||
| 48 | 0 | ▶ | if defined($self->{password}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | } | ||||||||||
| 50 | 0 | return $self->{password}; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 3 | ▶ | sub _build_password_digest { | ||||||||
|
Subroutine
_build_password_digest: called CC=2 SCAR=7.1
| |||||||||||
| 54 | 3 | my ($self) = @_; | |||||||||
| 55 | |||||||||||
| 56 | croak("Unable to build password digest from incomplete data") | ||||||||||
| 57 | 3 | ▶ | if not defined($self->{password}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | return crypt( | ||||||||||
| 60 | $self->{password}, | ||||||||||
| 61 | 3 | join('', ($self->crypt_salt_characters)[rand(64), rand(64)]) | |||||||||
| 62 | ); | ||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 2 | TRUE; | |||||||||