Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htpasswd problems!

Status
Not open for further replies.

rtb1

IS-IT--Management
Jul 17, 2000
73
ES
I'm not sure this is the right place to ask?

I'm setting up a password protection area on my site using .htpasswd (first time I'm trying this).

It seems to work but after getting access the first time it doesn't ask me anymore for a username and password even when I reconnect to the Internet?

As more people are working on the same computer it needs to ask for permission each time somebody connects to the Internet or when somebody tries to access the protected area!

This is the code in .htaccess:

AuthUserFile /home/******/cgi-bin/.htpasswd
AuthGroupFile /dev/null
AuthName "This Area is Restricted to Members Only."
AuthType Basic

<Limit GET>
require valid-user
</Limit>

Anybody knows what to do to achieve what I described above?

+ I would like to use the username data in some cgi scripts, any tips for this?

Thanks, [sig][/sig]
 
This is a web browser feature, and there isn't any way (that I know) of getting around it. To save having to keep re-entering the same user name and password, your browser will cache every user name and password that you use in the current session. Then, if you return to the same password protected page, you don't have to re-enter the password.

The only way that I know of having to re-enter the password is to close all copies of your browser, and then restart.

On the username front, there are environment variables that are set that will be available to your CGI script. I can't remember exactly what they are, but the following perl script, if run from your browser as a CGI, would show you:

#!/usr/bin/perl

print &quot;<HTML><HEAD></HEAD><BODY>\n&quot;;
foreach $Key (sort keys %ENV) {
print &quot;Var: &quot;, $Key, &quot; = &quot;, $ENV{$Key}, &quot;<BR>\n&quot;;
print &quot;</BODY></HTML>\n&quot;;
} [sig]<p> Andy Bold<br><a href=mailto: > </a><br><a href= > </a><br>"I've probably made most of the mistakes already, so hopefully you won't have to..." Me, most days.[/sig]
 
Your right, it does ask for the username when you close all browsers which I obviously didn't do untill now!

In my case, probably the only way to deal with this is to use a timer that asks for a username and password when a certain time period has expired and the browser wasn't closed.

Unfortunately your script resulted in an Internal Server Error. Any idea why?

Thanks for the help,

Raoul [sig][/sig]
 
Re the script, take a look in the error log to see what error message perl is throwing out. I should have said, but I was posting on the fly and didn't have chance to run the script via a web server myself before posting. Apolgies for that.

However, if you have set the permissions to allow execution by the &quot;owner&quot; of the web server process, then it's probably a missing line. Try putting the following as the first print line:

print &quot;Content-type: text/html\n\n&quot;;

This will send the required content type to the browser and web server, and everyone should be happy...

Sorry for any problems caused [sig]<p> Andy Bold<br><a href=mailto: > </a><br><a href= > </a><br>"I've probably made most of the mistakes already, so hopefully you won't have to..." Me, most days.[/sig]
 
Common, You are helping me, don't apologize! I should apologize to you as your suggestion:

print &quot;Content-type: text/html\n\n&quot;;

could very well be the reason as it wouldn't be the first time this line is causing me problems so I should have thought about it!

Unfortunately I don't have access to my error log!

I'm going to try again,

Thanks!

[sig][/sig]
 
Yes, that worked and it did return the user:

Var: REMOTE_USER = Raoul

Thanks! [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top