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

Re: [PBML] Digest Number 1755

Expand Messages
  • daymobrew@yahoo.com
    ... I have Apache 1.3.31. I added the following to my httpd.conf: AuthType Basic AuthName cgibin AuthUserFile
    Message 1 of 2 , Nov 22, 2004
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, GIDustin AKA Merlyn
      <gidustin@y...> wrote:
      > ok, I have the directory password protected, and my
      > CGI file inside of it, but how do I get my cgi file to
      > know which user logged on? Is it an ENV variable?
      >
      > - GIDustin
      >
      >
      > > Message: 4
      > > Date: Sat, 20 Nov 2004 13:19:24 +0000
      > > From: Jonathan Paton <jepaton@g...>
      > > Subject: Re: Login via Popup
      > >
      > > Dear Dustin,
      > >
      > > This is not directly a perl question. The access
      > > control mechanism is part
      > > of the web server (e.g. Apache). Try:
      > >
      > > http://httpd.apache.org/docs-2.0/howto/auth.html
      > >
      > > Jonathan Paton
      > >
      >

      I have Apache 1.3.31. I added the following to my httpd.conf:
      <Directory /usr/local/apache/cgi-bin>
      AuthType Basic
      AuthName cgibin
      AuthUserFile /usr/local/apache/cgibin-users
      require valid-user
      </Directory>

      cgibin-users was created with htpasswd.

      In this now protected directory is the 'printenv' script that comes
      with Apache.
      When I run it I am prompted for a username and password.
      It then displays the script's environment. The bit you are interested
      in is:
      REMOTE_USER="daymobrew"

      So, the logged in user is $ENV{'REMOTE_USER'}, or remote_user() if
      using CGI.pm.
      *I* don't know if this is a reliable method of getting the username -
      maybe it can be faked, though the fact that the authentication is
      server-side, I think this should be safe enough.
    Your message has been successfully submitted and would be delivered to recipients shortly.