Authen-Simple-PAM-0.2/0040755000076500007650000000000010361333660014300 5ustar chansenchansenAuthen-Simple-PAM-0.2/Build.PL0100644000076500007650000000053210361333660015571 0ustar chansenchansenuse strict; use Module::Build; my $build = Module::Build->new( license => 'perl', module_name => 'Authen::Simple::PAM', requires => { 'Authen::Simple' => 0, 'Authen::PAM' => 0, }, create_makefile_pl => 'traditional', create_readme => 1 ); $build->create_build_script; Authen-Simple-PAM-0.2/Changes0100644000076500007650000000026010361333660015566 0ustar chansenchansenRevision history for Perl extension Authen::Simple::PAM 0.2 2006-01-12 00:00 - Cleaned up error messages. No functional changes. 0.1 2006-01-03 00:00 - First release Authen-Simple-PAM-0.2/lib/0040755000076500007650000000000010361333660015046 5ustar chansenchansenAuthen-Simple-PAM-0.2/lib/Authen/0040755000076500007650000000000010361333660016272 5ustar chansenchansenAuthen-Simple-PAM-0.2/lib/Authen/Simple/0040755000076500007650000000000010361333660017523 5ustar chansenchansenAuthen-Simple-PAM-0.2/lib/Authen/Simple/PAM.pm0100644000076500007650000000642110361333660020476 0ustar chansenchansenpackage Authen::Simple::PAM; use strict; use warnings; use base 'Authen::Simple::Adapter'; use Authen::PAM qw[:constants]; use Params::Validate qw[]; our $VERSION = 0.2; __PACKAGE__->options({ service => { type => Params::Validate::SCALAR, default => 'login', optional => 1 } }); sub check { my ( $self, $username, $password ) = @_; my $service = $self->service; my $handler = sub { my @response = (); while (@_) { my $code = shift; my $message = shift; my $answer = undef; if ( $code == PAM_PROMPT_ECHO_ON ) { $answer = $username; } if ( $code == PAM_PROMPT_ECHO_OFF ) { $answer = $password; } push( @response, PAM_SUCCESS, $answer ); } return ( @response, PAM_SUCCESS ); }; my $pam = Authen::PAM->new( $service, $username, $handler ); unless ( ref $pam ) { my $error = Authen::PAM->pam_strerror($pam); $self->log->error( qq/Failed to authenticate user '$username' using service '$service'. Reason: '$error'/ ) if $self->log; return 0; } my $result = $pam->pam_authenticate; unless ( $result == PAM_SUCCESS ) { my $error = $pam->pam_strerror($result); $self->log->debug( qq/Failed to authenticate user '$username' using service '$service'. Reason: '$error'/ ) if $self->log; return 0; } $result = $pam->pam_acct_mgmt; unless ( $result == PAM_SUCCESS ) { my $error = $pam->pam_strerror($result); $self->log->debug( qq/Failed to authenticate user '$username' using service '$service'. Reason: '$error'/ ) if $self->log; return 0; } $self->log->debug( qq/Successfully authenticated user '$username' using service '$service'./ ) if $self->log; return 1; } 1; __END__ =head1 NAME Authen::Simple::PAM - Simple PAM authentication =head1 SYNOPSIS use Authen::Simple::PAM; my $pam = Authen::Simple::PAM->new( service => 'login' ); if ( $pam->authenticate( $username, $password ) ) { # successfull authentication } # or as a mod_perl Authen handler PerlModule Authen::Simple::Apache PerlModule Authen::Simple::PAM PerlSetVar AuthenSimplePAM_service "login" PerlAuthenHandler Authen::Simple::PAM AuthType Basic AuthName "Protected Area" Require valid-user =head1 DESCRIPTION PAM authentication. =head1 METHODS =over 4 =item * new This method takes a hash of parameters. The following options are valid: =over 8 =item * service PAM service. Defaults to C. service => 'sshd' =item * log Any object that supports C, C, C and C. log => Log::Log4perl->get_logger('Authen::Simple::PAM') =back =item * authenticate( $username, $password ) Returns true on success and false on failure. =back =head1 SEE ALSO L. L. =head1 AUTHOR Christian Hansen C =head1 COPYRIGHT This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Authen-Simple-PAM-0.2/Makefile.PL0100644000076500007650000000067410361333660016256 0ustar chansenchansen# Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Authen::Simple::PAM', 'VERSION_FROM' => 'lib/Authen/Simple/PAM.pm', 'PREREQ_PM' => { 'Authen::PAM' => '0', 'Authen::Simple' => '0' }, 'INSTALLDIRS' => 'site', 'PL_FILES' => {} ) ; Authen-Simple-PAM-0.2/MANIFEST0100644000076500007650000000021210361333660015421 0ustar chansenchansenBuild.PL Changes lib/Authen/Simple/PAM.pm Makefile.PL MANIFEST This list of files README t/01use.t t/02pod.t t/03podcoverage.t META.yml Authen-Simple-PAM-0.2/META.yml0100644000076500007650000000047310361333660015552 0ustar chansenchansen--- name: Authen-Simple-PAM version: 0.2 author: - 'Christian Hansen C' abstract: Simple PAM authentication license: perl requires: Authen::PAM: 0 Authen::Simple: 0 provides: Authen::Simple::PAM: file: lib/Authen/Simple/PAM.pm version: 0.2 generated_by: Module::Build version 0.2611 Authen-Simple-PAM-0.2/README0100644000076500007650000000265310361333660015163 0ustar chansenchansenNAME Authen::Simple::PAM - Simple PAM authentication SYNOPSIS use Authen::Simple::PAM; my $pam = Authen::Simple::PAM->new( service => 'login' ); if ( $pam->authenticate( $username, $password ) ) { # successfull authentication } # or as a mod_perl Authen handler PerlModule Authen::Simple::Apache PerlModule Authen::Simple::PAM PerlSetVar AuthenSimplePAM_service "login" PerlAuthenHandler Authen::Simple::PAM AuthType Basic AuthName "Protected Area" Require valid-user DESCRIPTION PAM authentication. METHODS * new This method takes a hash of parameters. The following options are valid: * service PAM service. Defaults to "login". service => 'sshd' * log Any object that supports "debug", "info", "error" and "warn". log => Log::Log4perl->get_logger('Authen::Simple::PAM') * authenticate( $username, $password ) Returns true on success and false on failure. SEE ALSO Authen::Simple. Authen::PAM. AUTHOR Christian Hansen "ch@ngmedia.com" COPYRIGHT This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Authen-Simple-PAM-0.2/t/0040755000076500007650000000000010361333660014543 5ustar chansenchansenAuthen-Simple-PAM-0.2/t/01use.t0100644000076500007650000000007310361333660015662 0ustar chansenchansenuse Test::More tests => 1; use_ok('Authen::Simple::PAM'); Authen-Simple-PAM-0.2/t/02pod.t0100644000076500007650000000027610361333660015656 0ustar chansenchansenuse Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Authen-Simple-PAM-0.2/t/03podcoverage.t0100644000076500007650000000036510361333660017372 0ustar chansenchansenuse Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok( { trustme => [ qr/^check$/ ] } );