You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kai <ve...@kokai.net> on 2003/12/09 03:51:11 UTC
About Authenticate Dialog
Hi List,
I am going to write a HTTP authentication by using mod_perl.And I wrote
some code like the following:
---
#!/usr/bin/perl -w
use CGI;
my $p=new CGI;
print $p->header(-status=>401,
-www_authenticate='Basic realm="test area"',
-type=>'text/html');
---
Now,if I open this script,the brower will pop a authenticate box.
I want to know,how can I get the id and password that the client inputed in
that authenticate box .
Would someone give any advice ?
Thanx.
Regards,
Kai
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: About Authenticate Dialog
Posted by Matthew Darwin <ma...@mdarwin.ca>.
In mod_perl 2:
sub handler {
my ($r) = shift;
my ($res, $password) = ($r->get_basic_auth_pw);
return $res if $res; #decline if not Basic
my $username = $r->user;
if ($username eq '') {
$r->note_basic_auth_failure;
$r->log_error ("no account given for uri=<" . $r->uri . ">");
return Apache::AUTH_REQUIRED;
}
# etc...
return Apache::OK;
}
Kai wrote:
> Hi List,
> I am going to write a HTTP authentication by using mod_perl.And I wrote
> some code like the following:
> ---
> #!/usr/bin/perl -w
> use CGI;
> my $p=new CGI;
> print $p->header(-status=>401,
> -www_authenticate='Basic realm="test area"',
> -type=>'text/html');
> ---
> Now,if I open this script,the brower will pop a authenticate box.
> I want to know,how can I get the id and password that the client inputed in
> that authenticate box .
> Would someone give any advice ?
> Thanx.
>
> Regards,
> Kai
>
>
>
--
Matthew Darwin
matthew@mdarwin.ca
http://www.mdarwin.ca
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: About Authenticate Dialog
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Kai wrote:
> Hi List,
> I am going to write a HTTP authentication by using mod_perl.
> Now,if I open this script,the brower will pop a authenticate box.
> I want to know,how can I get the id and password that the client inputed in
> that authenticate box .
> Would someone give any advice ?
see
http://www.modperlcookbook.org/code/ch13/Cookbook/Authenticate.pm
you can also read the authentication chapter online for free
http://www.modperlcookbook.org/chapters/ch13.pdf
--Geoff
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html