CGI-Auth-Basic

 view release on metacpan or  search on metacpan

eg/01_template.pl  view on Meta::CPAN

   %CGI::Auth::Basic::ERROR = error();
   my $auth = CGI::Auth::Basic->new(
               cgi_object     => $cgi,
               file           => './password.txt',
               http_charset   => 'ISO-8859-1',
               setup_pfile    => 1,
               logoff_param   => 'cik',
               changep_param  => 'changepassword',
               cookie_id      => 'passcookie',
               cookie_timeout => '10m',
               chmod_value    => 0777,
            );

   $auth->set_template(template());
   $auth->set_title(title());
   return $auth;
}

sub template {
   return login_form => <<"TEMPLATE",
<span class="error"><? PAGE_FORM_ERROR ?></span>

eg/02_turkish.pl  view on Meta::CPAN

   %CGI::Auth::Basic::ERROR = error();
   my $auth = CGI::Auth::Basic->new(
               cgi_object     => $cgi,
               file           => './password.txt',
               http_charset   => 'utf8',
               setup_pfile    => 1,
               logoff_param   => 'cik',
               changep_param  => 'parola_degistir',
               cookie_id      => 'parolakurabiyesi',
               cookie_timeout => '1h',
               chmod_value    => 0777,
            );

   $auth->set_template(template());
   $auth->set_title(title());
   return $auth;
}

sub template {
   return login_form => <<"TEMPLATE",
<span class="error"><?PAGE_FORM_ERROR?></span>

lib/CGI/Auth/Basic.pm  view on Meta::CPAN

   $self->{cgi}            = $o{cgi_object};
   $self->{program}        = $self->{cgi}->url  || EMPTY_STRING;

   # object tables           user specified         default
   $self->{cookie_id}      = $o{cookie_id}      || 'authpass';
   $self->{http_charset}   = $o{http_charset}   || 'ISO-8859-1';
   $self->{logoff_param}   = $o{logoff_param}   || 'logoff';
   $self->{changep_param}  = $o{changep_param}  || 'changepass';
   $self->{cookie_timeout} = $o{cookie_timeout} || EMPTY_STRING;
   $self->{setup_pfile}    = $o{setup_pfile}    || 0;
   $self->{chmod_value}    = $o{chmod_value}    || CHMOD_VALUE;
   $self->{use_flock}      = $o{use_flock}      || 1;
   $self->{hidden}         = $o{hidden}         || [];
   return;
}

sub exit_code {
   my $self = shift;
   my $code = shift || return;
   $self->{EXIT_PROGRAM} = $code if ref $code eq 'CODE';
   return;

lib/CGI/Auth/Basic.pm  view on Meta::CPAN

sub _update_pfile {
   my $self     = shift;
   my $password = shift;
   require IO::File;
   my $PASSWORD = IO::File->new;
   $PASSWORD->open( $self->{password_file_path}, '>' ) or $self->_fatal($ERROR{FILE_WRITE}." $!");
   flock $PASSWORD, Fcntl::LOCK_EX() if $self->{use_flock};
   my $pok = print {$PASSWORD} $self->_encode($password);
   flock $PASSWORD, Fcntl::LOCK_UN() if $self->{use_flock};
   $PASSWORD->close;
   return chmod $self->{chmod_value}, $self->{password_file_path};
}

sub _pfile_content {
   my $self = shift;
   require IO::File;
   my $PASSWORD = IO::File->new;
   $PASSWORD->open($self->{password_file_path}) or $self->_fatal($ERROR{FILE_READ}." $!");
   my $flat = do { local $/; my $rv = <$PASSWORD>; $rv };
   chomp $flat;
   $PASSWORD->close;

lib/CGI/Auth/Basic.pm  view on Meta::CPAN

module will send a password cookie to the user. Set this parameter 
if you want to alter the module's setting. Default is an empty string
(means; cookie is a session cookie, it'll be deleted as soon as the user 
closes all browser windows)

=item changep_param

Form area name for password change. Same as C<logoff_param>. Cosmetic
option.

=item chmod_value

Password file's chmod value. Default value is C<0777>. Change this value 
if you get file open/write errors or want to use different level of 
permission. Takes octal numbers like C<0777>.

=item use_flock

Default value is C<1> and C<flock()> will be used on filehandles. You can 
set this to zero to turn off flock for platforms that does not implement 
flock (like Win9x).

=item hidden



( run in 0.404 second using v1.01-cache-2.11-cpan-496ff517765 )