WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-03-2007, 08:15 PM
dmadance's Avatar
WebProWorld Member
 

Join Date: Jul 2003
Posts: 49
dmadance RepRank 0
Default htaccess and login

Does anyone have a good script that can create a login to a site protected by htaccess. Also does someone have a script to logout from a site protected by htaccess.

I was thinking the logout could be done with AJAX by asking for a url http://randomstring:randomstring@mysite.com and when that fails to somehow redirect to the homepage. Is this feasable? If somebody has already done this I would love the code.

I know one can do logins with "http://usernameassword@mysite.com", does anyone have a script of some sort that can take userame and password as inputs to a form, and only goes to the page if authenticated to go the protected site. I think this can be done with AJAX. I am very new to AJAX (just read AJAX in 10 minutes 10 minutes ago) so if someone out there knows this, I would appreciate the helps.
Reply With Quote
  #2 (permalink)  
Old 08-06-2007, 03:56 PM
WebProWorld Member
 

Join Date: Dec 2005
Posts: 90
JohneeMac RepRank 0
Default Re: htaccess and login

What happens with Javascript disabled?

Can you not use a more standard php / asp log in system?
Reply With Quote
  #3 (permalink)  
Old 08-06-2007, 05:35 PM
WebProWorld New Member
 

Join Date: Nov 2005
Posts: 8
gawotn RepRank 0
Default Re: htaccess and login

"Does anyone have a good script that can create a login to a site protected by htaccess."

I have used this program for years:

SiteInteractive.com - Account Manager Lite :: Free CGI Perl Script
Reply With Quote
  #4 (permalink)  
Old 08-06-2007, 06:07 PM
WebProWorld New Member
 

Join Date: Aug 2006
Posts: 9
trabar RepRank 0
Default Re: htaccess and login

I've used Siteinteractive's Pro version for years. I completely forgot I could use it on the other web site I have planned. After visiting their site again, it reminded me of why I bought it in the first place. (smile).

When I first got it, the tech support for the pro version was outstanding.

Judith
Book Club, Free Self Help Books, Free Fiction Books,Free Money Screensaver, Free Game, Affirmation Movie DVD and more at agoodread.com

P.S. I'm not an affiliate but I may change my mind because I've been very happy with their product.
__________________
Learn how to make RSS Feeds Free
http://www.agoodread.com
Reply With Quote
  #5 (permalink)  
Old 08-06-2007, 11:45 PM
WebProWorld New Member
 

Join Date: Jul 2003
Location: Australia
Posts: 4
chaoley RepRank 0
Default Re: htaccess and login

Try the following links for just about everything you might want to know about htaccess.

http://www.askapache.com/htaccess/apache-htaccess.html

http://www.javascriptkit.com/howto/htaccess.shtml
__________________
Southwind Web Services
www.sthwind.com
Reply With Quote
  #6 (permalink)  
Old 08-06-2007, 11:54 PM
dmadance's Avatar
WebProWorld Member
 

Join Date: Jul 2003
Posts: 49
dmadance RepRank 0
Default Re: htaccess and login

I have looked at the Siteinteractive solution, unfortunately it does too much. I don't need a program that creates the .htaccess file and stores information, I have all that already, I need a program that can login or logout from the directory that is already protected, and then redirect appropriately to my existing account creation scripts or the homepage.

I have not seen a way to do this other than the brute force method in the browser window for logout is to try to force a bogus authentication.
Reply With Quote
  #7 (permalink)  
Old 08-07-2007, 01:06 AM
dmadance's Avatar
WebProWorld Member
 

Join Date: Jul 2003
Posts: 49
dmadance RepRank 0
Default Re: htaccess and login

Ok, I figured out a way to do the login with a perl script. All I did was call a script that created a redirect through http-equiv to http://usernameassword@mysite.com. Seems to work great, only issue is that if you try to reauthenticate with bogus information, it keeps the previous authentication, which leads to my next problem.

I now need to figure out a way to do a logout of an htaccess protected file after being authenticated. I tried writing a script that forces a bogus authentication, this didn't seem to work, even though it did work when done through the browser window.
Reply With Quote
  #8 (permalink)  
Old 08-07-2007, 01:14 AM
e-dvertising's Avatar
WebProWorld New Member
 

Join Date: Oct 2005
Location: Graz / Austria / EC
Posts: 14
e-dvertising RepRank 0
Lightbulb Re: htaccess and login

As far as I know and understand .htaccess there is no possibility to logout from an htaccess-protected area, you have to close the browsers window (in FF you have to close _all_ windows!) to make the browser "forget" the login-information for that session.

So if you want do have a solution with "logout" you have to go for
- Session-IDs
- Cookies
- Combination SID and Cookie
...


Annotation: don't use a redirect or anything else like http://usernameassword@... in public 'cause that may cause to get the user/pass-combination in some browsers or even servers logs and history (e.g. some toolbars log that even to search engine results) and that might open up parts of protected areas.
__________________
http://e-dvertising.at/ : e-dvertising - Hinterdorfer & Edlinger OG
advertising | werbung - webdesign - fullservice - cms . Graz - Zeltweg / Austria

Last edited by e-dvertising : 08-07-2007 at 01:36 AM.
Reply With Quote
  #9 (permalink)  
Old 08-07-2007, 09:31 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,765
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: htaccess and login

e-dvertising is right. You don't actually "log in" to htaccess protected content, so there is no way to actually log out. The username and password prompt that you are shown are not shown by the server, they are generated by your browser. Every time that you access a protected page, the browser is prompted for your username and password. This means that you are actually re-authenticated every time you click on a link. So that you do not need to keep re-entering your password, the browser will remember the last good password either permanently or until the browser is closed. From the server end, you do not have the ability to override this functionality.

Please note, .htaccess IS NOT SECURE as all username/password combinations are transmitted in plain text and can be easily intercepted and used by unauthorized parties to gain access to the protected content.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #10 (permalink)  
Old 08-07-2007, 12:03 PM
jganders's Avatar
WebProWorld Member
 

Join Date: Jul 2007
Location: California, USA
Posts: 26
jganders RepRank 0
Default Re: htaccess and login

When authenticated using basic or digest authentication in apache, the username is stored in the http header REMOTE_USER. If you are using php, the username and password are also stored in the http header as PHP_AUTH_USER and PHP_AUTH_PW.
Regarding logout, cPanel has a logout link. It works as dmadance requires. I dont know if cPanel simply deletes the value for REMOTE_USER or something else entirely. But I use it all the time to switch between various remote databases managed with PHPmyAdmin.
Reply With Quote
  #11 (permalink)  
Old 08-07-2007, 01:58 PM
e-dvertising's Avatar
WebProWorld New Member
 

Join Date: Oct 2005
Location: Graz / Austria / EC
Posts: 14
e-dvertising RepRank 0
Default Re: htaccess and login

i don't know cPanel but i know differnt other panels _and_ i know phpMyAdmin, here you 've got different possibilities to handle the "login" and i guess the one you mentioned is not (only) htaccess-based but uses at least a combined method or even no htaccess at all, cause' esp. with FF you have to close _all_ instances to get rid of the user/pass combination which once has been entered to get a "second" chance to login with another one.
__________________
http://e-dvertising.at/ : e-dvertising - Hinterdorfer & Edlinger OG
advertising | werbung - webdesign - fullservice - cms . Graz - Zeltweg / Austria
Reply With Quote
  #12 (permalink)  
Old 08-07-2007, 02:34 PM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,765
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: htaccess and login

If you use a bad username/password combo to force the user to log out, the following happens:

First, the user wants to visit the secure site...
Browser: GET /secureplace/file.html
Server: 401 Unauthorized Authenticate Realm
Browser shows user a password prompt for the realm "Realm"
Browser: GET /secureplace/file.html AUTHENTICATION Realm username:pass
Server: 200 OK

Then the user clicks a link. Since the browser remembers that this directory requires authentication, it automatically includes the username and password.
Browser: GET /secureplace/otherfile.html AUTHENTICATION Realm username:pass
Server: 200 OK

If you use any process to change the login, such as using a URL with a bad username and password embedded, the following will occur:
Browser: GET /secureplace/someotherfile.html AUTHENTICATION Realm baduser:badpass
Server: 401 Unauthorized Authenticate Realm
Browser: GET /secureplace/someotherfile.html AUTHENTICATION Realm knowngooduser:knowngoodpassfromcache
Server: 200 OK
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog

Last edited by wige : 08-07-2007 at 02:38 PM.
Reply With Quote
  #13 (permalink)  
Old 08-08-2007, 06:59 AM
WebProWorld Veteran
 

Join Date: Jun 2005
Location: LA, USA
Posts: 535
Clint1 RepRank 1
Default Re: htaccess and login

Quote:
Originally Posted by dmadance View Post
Does anyone have a good script that can create a login to a site protected by htaccess. Also does someone have a script to logout from a site protected by htaccess.

I was thinking the logout could be done with AJAX by asking for a url http://randomstring:randomstring@mysite.com and when that fails to somehow redirect to the homepage. Is this feasable? If somebody has already done this I would love the code.

I know one can do logins with "http://usernameassword@mysite.com", does anyone have a script of some sort that can take userame and password as inputs to a form, and only goes to the page if authenticated to go the protected site. I think this can be done with AJAX. I am very new to AJAX (just read AJAX in 10 minutes 10 minutes ago) so if someone out there knows this, I would appreciate the helps.
(If you use cPanel), just it's "Web protect" or "Protect folders" area (the name depends on your skins used). Once you add a page or folder to this area, you have to enter a user and pass to get access to the page, and you can check the box to remember the login if wanted. No "logout" is required since you're logged out when you leave the page.
__________________
God Bless
-Clint
Reply With Quote
  #14 (permalink)  
Old 08-08-2007, 12:14 PM
jganders's Avatar
WebProWorld Member
 

Join Date: Jul 2007
Location: California, USA
Posts: 26
jganders RepRank 0
Default Re: htaccess and login

Quote:
Originally Posted by Clint1 View Post
(If you use cPanel), just it's "Web protect" or "Protect folders" area (the name depends on your skins used). Once you add a page or folder to this area, you have to enter a user and pass to get access to the page, and you can check the box to remember the login if wanted. No "logout" is required since you're logged out when you leave the page.
I dunno about this... on my Apache-cPanel protected folders when you provide uid/pw to login, you remain logged in for the duration of the browser session. You can leave the protected folder and come back all you want w/o having to log back in. The only logout is to close the browser. Clint, maybe you can provide an example of the behavior that you describe?
Reply With Quote
  #15 (permalink)  
Old 08-09-2007, 06:26 AM
WebProWorld Veteran
 

Join Date: Jun 2005
Location: LA, USA
Posts: 535
Clint1 RepRank 1
Default Re: htaccess and login

Quote:
Originally Posted by jganders View Post
I dunno about this... on my Apache-cPanel protected folders when you provide uid/pw to login, you remain logged in for the duration of the browser session. You can leave the protected folder and come back all you want w/o having to log back in. The only logout is to close the browser. Clint, maybe you can provide an example of the behavior that you describe?
Yes, that's correct. I should have mentioned that, but I didn't. It's a "session login" so-to-speak. I don't think that would be a problem though since no one else could login on another PC without a user & pass. It's the simplest way.
__________________
God Bless
-Clint
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How safe is Windows during login? Dragonsi Internet Security Discussion Forum 5 10-02-2005 10:01 AM
login problem pbrollwitme Flash Discussion Forum 7 09-01-2005 05:46 PM
Login functionality anthonyl Web Programming Discussion Forum 4 08-31-2004 11:16 PM
simple login jmdb71 Web Programming Discussion Forum 3 08-09-2004 11:27 AM
JS Error on login AlanMCSD WebProWorld: Guidelines/Announcements/Suggestions 0 10-27-2003 02:23 AM


Search Engine Optimization by vBSEO 3.2.0