#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    5
    Rep 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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    35
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    5
    Rep 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
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    35
    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    5
    Rep 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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    35
    '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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    5
    Rep Power
    0
    Thanx i hope that will help

IMN logo majestic logo threadwatch logo seochat tools logo