| 1 | # Apache::AppSamurai::AuthTest - Sample AppSamurai authentication plugin. | ||
| 2 | |||
| 3 | ##### DO NOT USE THIS! THIS IS A SAMPLE! ################################# | ||
| 4 | #### Feel free to base your custom authenticaiton module on it, though #### | ||
| 5 | |||
| 6 | # $Id: AuthTest.pm,v 1.4 2007/09/13 07:00:16 pauldoom Exp $ | ||
| 7 | |||
| 8 | package Apache::AppSamurai::AuthTest; | ||
| 9 | use strict; | ||
| 10 | |||
| 11 | use vars qw($VERSION @ISA); | ||
| 12 | $VERSION = substr(q$Revision: 1.4 $, 10, -1); | ||
| 13 | |||
| 14 | use Carp; | ||
| 15 | use Apache::AppSamurai::AuthBase; | ||
| 16 | |||
| 17 | @ISA = qw( Apache::AppSamurai::AuthBase ); | ||
| 18 | |||
| 19 | sub Configure { | ||
| 20 | my $self = shift; | ||
| 21 | |||
| 22 | # Pull defaults from AuthBase and save. | ||
| 23 | $self->SUPER::Configure(); | ||
| 24 | my $conft = $self->{conf}; | ||
| 25 | |||
| 26 | # Initial configuration. Put defaults here before the @_ args are | ||
| 27 | # pulled in. | ||
| 28 | $self->{conf} = { %{$conft}, | ||
| 29 | TestThing => "MegaGarbage", | ||
| 30 | @_, | ||
| 31 | }; | ||
| 32 | return 1; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub Initialize { | ||
| 36 | my $self = shift; | ||
| 37 | |||
| 38 | # Well, this is a dumb test module, so there isn't anything to do. | ||
| 39 | |||
| 40 | return 1; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | # Make a backdoor. Yes, in case you didn't read above, let me reiterate: | ||
| 45 | # DO NOT USE THIS MODULE IN PRODUCTION!!!! | ||
| 46 | sub Authenticator { | ||
| 47 | my $self = shift; | ||
| 48 | my $user = shift; | ||
| 49 | my $pass = shift; | ||
| 50 | |||
| 51 | if (($user eq 'satan') && ($pass eq '6666')) { | ||
| 52 | return 1; # Ok! | ||
| 53 | } | ||
| 54 | |||
| 55 | # DEFAULT DENY # | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |