Apache-AppSamurai

 view release on metacpan or  search on metacpan

lib/Apache/AppSamurai/AuthSimple.pm  view on Meta::CPAN

    return 1;
}


# Authenticate using Authen::Simple (which in turn calls the configured
# adaptor submodule)
sub Authenticator {
    my $self = shift;
    my $user = shift;
    my $pass = shift;

    # Multiple layers of abstraction rock!  (We are passing authentication
    # information to Authen::Simple which is passing it to its adaptor
    # submodule...)
    ($self->{authen}->authenticate($user, $pass)) && (return 1);

    $self->AddError('warn', "Authentication failure with $self->{conf}{SubModule} for user: \"$user\"");

    # DEFAULT DENY # 
    return 0;
}


# Logging methods for the Authen:Simple submodules to callback to
sub debug {
    shift->_simplelog('debug', @_);
}

sub error {
    shift->_simplelog('error', @_);
}

sub info {
    shift->_simplelog('info', @_);
}

sub warn {
    shift->_simplelog('warn', @_);
}

sub _simplelog {
    my $self = shift;
    my $severity = shift;

    # For now, squeezing multiple log lines into one seems more reasonable
    # for auth submodules.  This can be changed if submodules are shown
    # to send a lot of multiline log messages
    my $msg = join(", ", @_);

    $msg =~ s/\n/ /gs;

    $self->AddError($severity, $msg);
}

1; # End of Apache::AppSamurai::AuthSimple

__END__

=head1 NAME

Apache::AppSamurai::AuthSimple - Check credentials with Authen::Simple framework

=head1 SYNOPSIS

The module is selected and configured inside the Apache configuration.

 # Example with an authname of "fred" for use as part of an Apache config.

 # Configure as an authentication method (Authen::Simple::Passwd shown)
 PerlSetVar fredAuthMethods "AuthSimplePasswd"

 # Set auth method options (Authen::Simple::Passwd "path" option shown)
 PerlSetVar fredAuthSimplePasswdpath "/var/www/conf/passwordfile"

=head1 DESCRIPTION

This L<Apache::AppSamurai|Apache::AppSamurai> authentication module checks a
username and password using the Authen::Simple auth framework and a supported
Authen::Simple::XXX adaptor module. If this sounds confusing, read on and
examine the examples.

This module opens up authentication access to a wide array of options including
PAM, LDAP, Kerberos, and even SSH.

=head1 USAGE

Basic L<Apache::AppSamurai::AuthBase|Apache::AppSamurai::AuthBase>
configuration options are supported.  Additional options are described
below.  The following must be preceded by the auth name and the auth
module name, I<AuthSimple>, followed by the adaptor submodule for
L<Authen::Simple|Authen::Simple> to use, and finally the name of the
parameter to set. (This will end up being passed directly to the adaptor
submodule.)

For example, if you wish to set the
L<Authen::Simple::Kerberos|Authen::Simple::Kerberos> C<realm> value for
the authname "Jerry", you would use:

 PerlSetVar JerryAuthSimpleKerberosrealm "REALM.REALMY.COM"

Note that the configuration key, "realm", is in all lower case to match
the key L<Authen::Simple::Kerberos|Authen::Simple::Kerberos> expects.

Here is another example, this time setting the
L<Authen::Simple::LDAP|Authen::Simple::LDAP> and the authname "GRAVY":

 PerlSetVar GRAVYAuthSimpleLDAPhost "dir.lovemesomeldap.org"
 PerlSetVar GRAVYAuthSimpleLDAPbasedn "ou=People,dc=lovemesomeldap,dc=org"

Check the documentation for the specific L<Authen::Simple|Authen::Simple>
adaptor you wish to use for a list of configuration parameters.  All
parameters that can be passed to the I<new> constructor of the adaptor
module can be set, with the exception of the I<log> parameter which is
handled by L<Apache::AppSamurai::AuthSimple|Apache::AppSamurai::AuthSimple>
directly.

See L<Apache::AppSamurai|Apache::AppSamurai> for more general configuration
information, or the F<examples/conf/> directory in the Apache::AppSamurai
distribution for examples.

=head1 METHODS



( run in 0.982 second using v1.01-cache-2.11-cpan-39bf76dae61 )