CGI-Application-Plugin-Authentication

 view release on metacpan or  search on metacpan

lib/CGI/Application/Plugin/Authentication/Driver.pm  view on Meta::CPAN

                    DSN      => '...',
                    TABLE    => 'users',
                    CONSTRAINTS => {
                        username         => '__CREDENTIAL_1__',
                        'rot13:password' => '__CREDENTIAL_2__',
                    }
                    FILTERS => { rot13 => \&rot13_filter },
                ],

 sub rot13_filter {
     my $param = shift;
     my $value = shift;
     $value =~ tr/A-Za-z/N-ZA-Mn-za-m/;
     return $value;
 }

Please see the documentation for the driver that you are using to make sure that it supports encoded
fields.


=head2 Builtin Filters

Here is a list of the filters that are provided with this module:

=over 4

=item crypt - provided by perl C<crypt> function

=item MD5 - requires Digest::MD5

=item SHA1 - requires Digest::SHA1

=item uc - provided by the perl C<uc> function

=item lc - provided by the perl C<lc> function

=item trim - removed whitespace from the start and end of the field

=back


=head1 METHODS

=head2 new

This is a constructor that can create a new Driver object.  It requires an Authentication object as its
first parameter, and any number of other parameters that will be used as options depending on which
Driver object is being created.  You shouldn't need to call this as the Authentication plugin takes care
of creating Driver objects.

=cut

sub new {
    my $class = shift;
    my $self = {};
    my $authen = shift;
    my @options = @_;

    bless $self, $class;
    $self->{authen} = $authen;
    Scalar::Util::weaken($self->{authen}); # weaken circular reference
    $self->{options} = \@options;
    $self->initialize;
    return $self;
}

=head2 initialize

This method will be called right after a new Driver object is created.  So any startup customizations
can be dealt with here.

=cut

sub initialize {
    my $self = shift;
    # override this in the subclass if you need it
    return;
}

=head2 options

This will return a list of options that were provided when this driver was configured by the user.

=cut

sub options { return (@{$_[0]->{options}}) }

=head2 authen

This will return the underlying L<CGI::Application::Plugin::Authentication> object.  In most cases it will
not be necessary to access this.

=cut

sub authen { return $_[0]->{authen} }

=head2 find_option

This method will search the Driver options for a specific key and return
the value it finds.

=cut

sub find_option {
    my $self = shift;
    my $key = shift;
    my @options = $self->options;
    my $marker = 0;
    foreach my $option (@options) {
        if ($marker) {
            return $option;
        } elsif ($option eq $key) {
            # We need the next element
            $marker = 1;
        }
    }
    return;
}

=head2 verify_credentials



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