Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 11th, 2004, 01:20 PM
kenahans kenahans is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 kenahans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
password protected page (CGI) Urgent

Hey, i really need help fast with this:

I want one page that users have to log in to get access to. Can someone help me write that script? I have no idea how to do it . i am not good in python.

Ken-A

Reply With Quote
  #2  
Old May 11th, 2004, 01:34 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
Are you using Apache, IIS or something else?

If Apache, then look into htaccess files - move the secure documents to a new folder and you can make Apache handle the logon for you.

Alternatively, if it must be done by Python in a CGI script, make sure the textbox is inputtype=password so it conceals the password, don't pass the password in the querystring like "username=fred&password=hello".

Compare the password entered with a password stored in a file which is not web accessible, and has the appropriate security settings, and make sure to turn off directory listing for the secured area.

Reply With Quote
  #3  
Old May 11th, 2004, 01:55 PM
kenahans kenahans is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 kenahans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the server is using apache. but my problem is that i have no idea how to do any of those things u told me about :/. That is why i am so frustrated :/. Do you think you could help me with an exaple code? If u want to, u can e-mail it to me, if u dont want others to see (kenahans@hotmail.com(

Ken-A

Reply With Quote
  #4  
Old May 11th, 2004, 02:22 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
It would probably be easiest to look at something like this:

http://www.freewebmasterhelp.com/tutorials/htaccess

Make a new folder and make it web accessable, then make a.htaccess file in it following that tutorial.

Sorry, but I haven't used them myself, that's why I can only link to a guide.

Reply With Quote
  #5  
Old May 11th, 2004, 02:32 PM
kenahans kenahans is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 kenahans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What about that other option u wrote about? Checking a file, have u used that before (i REALLY hope u have), or is u know how to do it, i would really appriciate it if u could show me how. the last option (not htaccess) is acctually the one i am after.

Ken-A

Reply With Quote
  #6  
Old May 11th, 2004, 05:04 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
'Fraid not, but I'll have a go...

Code:
import cgi

print "Content-type: text/plain\n\n"

realpassword = file('/somewhere/not/on/the/web/password.txt', 'r').read()
realpassword = realpassword.strip()

form = cgi.FieldStorage()
if form['passwd'] == password:
    # do something
else:
    print "Login Failed"


Pair it with a html form elsewhere:

Code:
<form name="loginForm" action="login.py" method="post">
<p>Username: <input type="text" /></p>
<p>Password: <input type="password" /></p>
</form>


The thing about this sort of script is that you're very limited in what you can do when they get the password right. You can't just redirect them to another page - because the page itself isn't secured. You could load a file and send it to the browser, but that's about it without going into large amounts of writing your own application.

Reply With Quote
  #7  
Old May 11th, 2004, 05:17 PM
kenahans kenahans is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 kenahans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanx i hope that will help

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > password protected page (CGI) Urgent


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway