You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@apache.org on 2001/04/02 21:30:41 UTC
cvs commit: modperl-2.0/xs/maps apache_functions.map
dougm 01/04/02 12:30:40
Modified: t/hooks authen.t
t/hooks/TestHooks authen.pm
xs modperl_xs_util.h
xs/maps apache_functions.map
Added: xs/Apache/Access Apache__Access.h
Log:
add get_basic_auth_pw() wrapper and tests
Revision Changes Path
1.2 +3 -1 modperl-2.0/t/hooks/authen.t
Index: authen.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/hooks/authen.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- authen.t 2001/04/02 09:09:40 1.1
+++ authen.t 2001/04/02 19:30:22 1.2
@@ -4,7 +4,7 @@
use Test;
use Apache::TestRequest;
-plan tests => 3;
+plan tests => 4;
my $location = "/TestHooks::authen";
@@ -15,5 +15,7 @@
ok $rc == 401;
ok GET_OK $location, username => 'dougm', password => 'foo';
+
+ok ! GET_OK $location, username => 'dougm', password => 'wrong';
1.2 +12 -1 modperl-2.0/t/hooks/TestHooks/authen.pm
Index: authen.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/hooks/TestHooks/authen.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- authen.pm 2001/04/02 09:09:40 1.1
+++ authen.pm 2001/04/02 19:30:27 1.2
@@ -7,7 +7,18 @@
sub handler {
my $r = shift;
- #auth api not complete yet
+
+ my($rc, $sent_pw) = $r->get_basic_auth_pw;
+
+ return $rc if $rc != 0;
+
+ my $user = $r->user;
+
+ unless ($user eq 'dougm' and $sent_pw eq 'foo') {
+ $r->note_basic_auth_failure;
+ return 401;
+ }
+
0;
}
1.4 +9 -0 modperl-2.0/xs/modperl_xs_util.h
Index: modperl_xs_util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/modperl_xs_util.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- modperl_xs_util.h 2001/03/13 06:49:12 1.3
+++ modperl_xs_util.h 2001/04/02 19:30:31 1.4
@@ -9,6 +9,15 @@
# define dITEMS I32 items = SP - MARK
#endif
+#define mpxs_PPCODE(code) STMT_START { \
+ SP -= items; \
+ code; \
+ PUTBACK; \
+} STMT_END
+
+#define PUSHs_mortal_iv(iv) PUSHs(sv_2mortal(newSViv(iv)))
+#define PUSHs_mortal_pv(pv) PUSHs(sv_2mortal(newSVpv((char *)pv,0)))
+
#define mpxs_sv_grow(sv, len) \
(void)SvUPGRADE(sv, SVt_PV); \
SvGROW(sv, len+1)
1.1 modperl-2.0/xs/Apache/Access/Apache__Access.h
Index: Apache__Access.h
===================================================================
static XS(MPXS_ap_get_basic_auth_pw)
{
dXSARGS;
request_rec *r;
const char *sent_pw = NULL;
int rc;
mpxs_usage_items_1("r");
mpxs_PPCODE({
r = mp_xs_sv2_r(ST(0));
rc = ap_get_basic_auth_pw(r, &sent_pw);
EXTEND(SP, 2);
PUSHs_mortal_iv(rc);
if (rc == OK) {
PUSHs_mortal_pv(sent_pw);
}
else {
PUSHs(&PL_sv_undef);
}
});
}
1.8 +1 -1 modperl-2.0/xs/maps/apache_functions.map
Index: apache_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- apache_functions.map 2001/03/25 22:32:11 1.7
+++ apache_functions.map 2001/04/02 19:30:37 1.8
@@ -106,7 +106,7 @@
#MODULE=Apache::Auth
ap_auth_name
ap_auth_type
- ap_get_basic_auth_pw
+ ap_get_basic_auth_pw | MPXS_ | r
ap_note_auth_failure
ap_note_basic_auth_failure
ap_note_digest_auth_failure