Geoffrey Young wrote:
> ok, I did some investigating and I really think that the mod_perl API is
> troubled wrt auth_type.  from what I tell, $r->auth_type returns the
> per-dir AuthType config, leaving no way to access r->ap_auth_type.

sorry for making the list listen to my thoughts whilst I sort things out.
the answer should have been obvious but I didn't see it.  anyway, the
attached patch fixes both the mod_perl API and the compat layer.  all tests
pass (for me at least).

--Geoff

Index: Changes
===================================================================
RCS file: /home/cvspublic/modperl-2.0/Changes,v
retrieving revision 1.124
diff -u -r1.124 Changes
--- Changes     12 Feb 2003 23:42:23 -0000      1.124
+++ Changes     14 Feb 2003 19:11:16 -0000
@@ -10,6 +10,12 @@
 
 =item 1.99_09-dev
 
+Open up r->ap_auth_type to make it possible to write custom
+authen handlers that don't rely on Basic or ap_* functions.
+Also, fix Apache::compat $r->connection->auth_type to use
+r->ap_auth_type and make both that and $r-connection->user
+writable. [Geoffrey Young]
+
 Add Apache::compat methods: $r->connection->auth_type and
 $r->connection->user (requires 'PerlOptions +GlobalRequest') + tests
 [Stas]
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.77
diff -u -r1.77 compat.pm
--- lib/Apache/compat.pm        12 Feb 2003 23:42:23 -0000      1.77
+++ lib/Apache/compat.pm        14 Feb 2003 19:11:16 -0000
@@ -534,8 +534,8 @@
 
 # auth_type and user records don't exist in 2.0 conn_rec struct
 # 'PerlOptions +GlobalRequest' is required
-sub auth_type { Apache->request->auth_type }
-sub user      { Apache->request->user      }
+sub auth_type { shift; Apache->request->ap_auth_type(@_) }
+sub user      { shift; Apache->request->user(@_)      }
 
 1;
 __END__
Index: t/response/TestCompat/conn_authen.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/response/TestCompat/conn_authen.pm,v
retrieving revision 1.1
diff -u -r1.1 conn_authen.pm
--- t/response/TestCompat/conn_authen.pm        12 Feb 2003 23:42:23 -0000      1.1
+++ t/response/TestCompat/conn_authen.pm        14 Feb 2003 19:11:16 -0000
@@ -1,6 +1,6 @@
 package TestCompat::conn_authen;
 
-# simply check that we can retrieve:
+# compat checks for
 #   $r->connection->auth_type
 #   $r->connection->user
 # both records don't exist in 2.0 conn_rec and therefore require
@@ -16,19 +16,47 @@
 use Apache::Constants qw(OK REMOTE_HOST);
 
 sub handler {
+
     my $r = shift;
 
+    my $req_auth_type = $r->connection->auth_type || '';
+
+    die "request auth_type is '$req_auth_type', should be empty"
+        if $req_auth_type;
+
+    # get_basic_auth_pw populates $r->user and $r->ap_auth_type
     my($rc, $sent_pw) = $r->get_basic_auth_pw;
 
     return $rc if $rc != Apache::OK;
 
-    my $auth_type = $r->connection->auth_type || '';
-    die "auth_type is '$auth_type', should be 'Basic'" 
-        unless $auth_type eq 'Basic';
+    $req_auth_type = $r->connection->auth_type || '';
+
+    die "request auth_type is '$req_auth_type', should be 'Basic'"
+        unless $req_auth_type eq 'Basic';
+
+    my $config_auth_type = $r->auth_type || '';
+
+    die "httpd.conf auth_type is '$config_auth_type', should be 'Basic'"
+        unless $config_auth_type eq 'Basic';
 
     my $user = $r->connection->user || '';
-    die "user is '$user', while expecting 'dougm'"
+
+    die "user is '$user', should be 'dougm'"
         unless $user eq 'dougm';
+
+    # make sure we can set both
+    $r->connection->auth_type('sailboat');
+    $r->connection->user('geoff');
+
+    $user = $r->connection->user || '';
+
+    die "user is '$user', should be 'geoff'"
+        unless $user eq 'geoff';
+
+    $req_auth_type = $r->connection->auth_type || '';
+
+    die "request auth_type is '$req_auth_type', should be 'sailboat'"
+        unless $req_auth_type eq 'sailboat';
 
     OK;
 }
Index: xs/maps/apache_structures.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/apache_structures.map,v
retrieving revision 1.18
diff -u -r1.18 apache_structures.map
--- xs/maps/apache_structures.map       12 Jan 2003 02:31:54 -0000      1.18
+++ xs/maps/apache_structures.map       14 Feb 2003 19:11:17 -0000
@@ -46,7 +46,7 @@
    content_languages
 >  vlist_validator
    user
--  ap_auth_type #should use ap_auth_type function instead
+   ap_auth_type
 ~  no_cache
    no_local_copy
    unparsed_uri


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to