The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
password protected page (CGI) Urgent
Discuss password protected page (CGI) Urgent in the Python Programming forum on Dev Shed. password protected page (CGI) Urgent Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 11th, 2004, 01:20 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
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
|

May 11th, 2004, 01:34 PM
|
|
|
|
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.
|

May 11th, 2004, 01:55 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
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
|

May 11th, 2004, 02:22 PM
|
|
|
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.
|

May 11th, 2004, 02:32 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
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
|

May 11th, 2004, 05:04 PM
|
|
|
'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.
|

May 11th, 2004, 05:17 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Thanx  i hope that will help 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|