Loading ...
Sorry, an error occurred while loading the content.
 

Anonymous login with Stein

Expand Messages
  • David Arnold
    All, I have this in my httpd.conf: PerlOptions +GlobalRequest AuthName Anonymous AuthType Basic PerlAuthenHandler Apache::AuthAnon
    Message 1 of 2 , Jul 1, 2004
      All,

      I have this in my httpd.conf:

      <Location /protected>
      PerlOptions +GlobalRequest
      AuthName Anonymous
      AuthType Basic
      PerlAuthenHandler Apache::AuthAnon
      require valid-user
      PerlSetVar Anonymous anonymous|anybody
      </Location>

      Here is the handler:

      package Apache::AuthAnon;
      # file: Apache/AuthAnon.pm

      use strict;
      use Apache::Constants qw(:common);

      my $email_pat='[.\w-]+\@\w+\.[.\w]*[^.]';
      my $anon_id="anonymous";

      sub handler {
      my $r=shift;

      my($res,$sent_pwd)=$r->get_basic_auth_pw;
      return $res if $res!=OK;

      my $user=lc $r->connection->user;
      my $reason="";

      my $check_id=$r->dir_config("Anonymous") || $anon_id;

      $reason="user did not enter a valid anonymous username: "
      unless $user=~/^$check_id/i;

      $reason="user did not enter an email address password: "
      unless $sent_pwd=~/^$email_pat$/o;

      if ($reason) {
      $r->note_basic_auth_failure;
      $r->log_reason($reason,$r->filename);
      return AUTH_REQUIRED;
      }

      $r->notes(AuthAnonPassword=>$sent_pwd);

      return OK;
      }

      1;
      __END__

      When I attempt to access the location (username: anonymous, password:
      darnold@...) I get this in my error_log:

      [Thu Jul 01 13:38:30 2004] [error] [client 127.0.0.1] Usage:
      Apache::RequestRec::notes(obj, val=NULL) at
      /home/darnold/modperl/Apache/AuthAnon.pm line 33.\n

      If I comment this line of code:

      # $r->notes(AuthAnonPassword=>$sent_pwd);

      Then I get this in my error_log:

      /darnold/modperl/Apache/AuthAnon.pm line 33.\n
      [Thu Jul 01 13:55:30 2004] [error] [client 127.0.0.1] Undefined subroutine
      &Apache::AuthAnon::handler called.\n

      Can someone explain what is going on and provide a workaround?



      --
      Report problems: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
      List etiquette: http://perl.apache.org/maillist/email-etiquette.html
    • Geoffrey Young
      ... your script was written for mod_perl 1.0, but you seem to be using mod_perl 2.0 for your server. there will be a few things you will need to change to get
      Message 2 of 2 , Jul 1, 2004
        > use Apache::Constants qw(:common);

        >
        > [Thu Jul 01 13:38:30 2004] [error] [client 127.0.0.1] Usage:
        > Apache::RequestRec::notes(obj, val=NULL) at
        > /home/darnold/modperl/Apache/AuthAnon.pm line 33.\n

        your script was written for mod_perl 1.0, but you seem to be using mod_perl
        2.0 for your server. there will be a few things you will need to change to
        get your handler running properly. see the porting documentation at
        perl.apache.org.

        >
        > If I comment this line of code:
        >
        > # $r->notes(AuthAnonPassword=>$sent_pwd);
        >
        > Then I get this in my error_log:
        >
        > /darnold/modperl/Apache/AuthAnon.pm line 33.\n
        > [Thu Jul 01 13:55:30 2004] [error] [client 127.0.0.1] Undefined subroutine
        > &Apache::AuthAnon::handler called.\n

        this simply means that your code did not compile cleanly, so the handler()
        subroutine never got defined in the Apache::AuthAnon namespace.

        HTH

        --Geoff

        --
        Report problems: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
        List etiquette: http://perl.apache.org/maillist/email-etiquette.html
      Your message has been successfully submitted and would be delivered to recipients shortly.