Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Basic http authentication in Perl

by smr (Initiate)
on Mar 23, 2001 at 04:25 UTC ( #66520=perlquestion: print w/replies, xml ) Need Help??
smr has asked for the wisdom of the Perl Monks concerning the following question:

Hello everybody!

The following script is written in PHP and does basic http authentication.
Now I have to do this in Perl, but I don't know how to do it.
Actually i'm a real Perl beginner :-(
Can anybody help me or tell me where I can find written help or code examples?

<? if(!isset($PHP_AUTH_USER)) { Header("WWW-Authenticate: Basic realm=\"myrealm\""); Header("HTTP/1.0 401 Unauthorized"); echo ("Acces denied"); exit; } else { if ($PHP_AUTH_USER!= "user" || $PHP_AUTH_PW!= "password") { Header("WWW-Authenticate: Basic realm=\"myrealm\""); Header("HTTP/1.0 401 Unauthorized"); echo ("Acces denied"); exit; } } ?>

Thanks in advance!

Sven Rudolph

P.S. Sorry if this is a FAQ.

Edit: chipmunk 2001-03-22

Replies are listed 'Best First'.
Re: Basic http authentication in Perl
by sutch (Curate) on Mar 23, 2001 at 04:44 UTC
      Thanks for your quick reply!

      I think I will find my answers there, but it seems to me that this is much more complicated in Perl than it was in PHP.



        I believe that you may also use to do handle basic authentication, but I've moved completely away from basic authentication (and the annoying popup windows) to creating HTML forms for login.

        The amount of complication really depends on your web server and how you want to use basic authentication. With Apache you can use an .htaccess file to require users to login with a username and password. I've rarely used that method because I was not able to find a way to log users out or to change identities--I wanted more control. If you are looking for the least complex method of authentication, I recommend that you check your web server's documentation.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://66520]
Approved by root
erix is always in favour of code-revolutions
[Lady_Aleena]: Well, right now, I"m looking at modules where I put randomness that aren't in my RolePlaying/Random dir, like RolePlaying:: Character:: Alignment that is mostly about random_alignment than expand_alignment.
[erix]: cute

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-05-27 20:32 GMT
Find Nodes?
    Voting Booth?