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

[mp2] PerlAccessHandler not overriding PerlAuthenHandler

Expand Messages
  • angie ahl
    Hi everyone. I think I only have 2 hurdles left to get my mp1 stuff running under mp2 I have an access handler that overrides my PerlAuthenHandler for a couple
    Message 1 of 3 , Jan 30, 2005
    • 0 Attachment
      Hi everyone.

      I think I only have 2 hurdles left to get my mp1 stuff running under mp2

      I have an access handler that overrides my PerlAuthenHandler for a
      couple of locations:

      Here's the accesshandler:

      use Apache::Constants qw(OK);
      use strict;
      use warnings;

      sub handler {
      my $r = shift;
      return Apache::OK unless $r->some_auth_required;
      if (($r->uri eq '/init.html') || ($r->uri eq '/favicon.ico') ||
      ($r->uri =~m#^/perl/#)) {
      warn "uri is " . $r->uri;
      $r->set_handlers(PerlAuthenHandler => []);
      }
      return Apache::OK;
      }
      1;

      and here's the httpd.conf

      <Location "/">
      PerlAccessHandler angies::access

      AuthName "angies"
      AuthType Basic
      #authenticate via DBI
      PerlAuthenHandler Apache::AuthDBI::authen

      PerlSetVar Auth_DBI_authoritative on

      PerlSetVar Auth_DBI_data_source DBI:mysql:db
      PerlSetVar Auth_DBI_username un
      PerlSetVar Auth_DBI_password pw
      #DBI->connect($data_source, $username, $password)

      PerlSetVar Auth_DBI_pwd_table siteusers
      PerlSetVar Auth_DBI_uid_field realmun
      PerlSetVar Auth_DBI_pwd_field realmpw
      #SELECT pwd_field FROM pwd_table WHERE uid_field=$user

      require valid-user
      </Location>

      the accesshandler is being called as it is printing the uri in the
      log. and it is the right uri.

      and I've tried all of the following to overide the AuthenHandler

      $r->set_handlers(PerlAuthenHandler => []);
      $r->set_handlers(PerlAuthenHandler => undef)
      $r->set_handlers(PerlAuthenHandler => [\&OK]);

      None seem to work, as in the AuthenHandler is prompting for auth under
      the locations that are being overridden.

      I've run out of ideas.

      The accesshandler used to say Return OK rather than return Apache::OK
      but I got a barewords error and other people seem to use Apache::OK
      although I'm finding it hard to work out what's going on I've read so
      many docs now ;)

      Thanks

      Angie
    • Geoffrey Young
      ... those only remove the PerlAuthenHandler from the handler chain. that is, since you probably have mod_auth installed, apache will move first to mod_perl
      Message 2 of 3 , Jan 30, 2005
      • 0 Attachment
        > and I've tried all of the following to overide the AuthenHandler
        >
        > $r->set_handlers(PerlAuthenHandler => []);
        > $r->set_handlers(PerlAuthenHandler => undef)

        those only remove the PerlAuthenHandler from the handler chain. that is,
        since you probably have mod_auth installed, apache will move first to
        mod_perl then, when mod_perl says "I have no handlers to run," it will move
        to mod_auth, which will then attempt it's authentiation.

        > $r->set_handlers(PerlAuthenHandler => [\&OK]);

        this is the correct approach - OK means "I authenticated" and lets apache
        know that it should _not_ call mod_auth.

        however, the symbol OK doesn't exist in your setup, so you are essentially
        passing undef. the proper solution is

        $r->set_handlers(PerlAuthenHandler => \&Apache::OK);

        HTH

        --Geoff
      • Stas Bekman
        ... I suppose because angie is using the mp1 legacy code via Apache::compat: use Apache::Constants qw(OK); why not drop that and use the pure mp2 API? i.e.
        Message 3 of 3 , Jan 30, 2005
        • 0 Attachment
          Geoffrey Young wrote:

          >>$r->set_handlers(PerlAuthenHandler => [\&OK]);
          >
          >
          > this is the correct approach - OK means "I authenticated" and lets apache
          > know that it should _not_ call mod_auth.
          >
          > however, the symbol OK doesn't exist in your setup, so you are essentially
          > passing undef. the proper solution is
          >
          > $r->set_handlers(PerlAuthenHandler => \&Apache::OK);

          I suppose because angie is using the mp1 legacy code via Apache::compat:

          use Apache::Constants qw(OK);

          why not drop that and use the pure mp2 API? i.e. Apache::Const

          --
          __________________________________________________________________
          Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
          http://stason.org/ mod_perl Guide ---> http://perl.apache.org
          mailto:stas@... http://use.perl.org http://apacheweek.com
          http://modperlbook.org http://apache.org http://ticketmaster.com
        Your message has been successfully submitted and would be delivered to recipients shortly.