Forum Moderators: phranque

Message Too Old, No Replies

read a data file from a web-page in apache

apache,loginpage

         

ravi18s

7:19 am on May 14, 2009 (gmt 0)

10+ Year Member



I have stored a data file named data.txt in htdocs directory.
--------------data.txt-----------
abc
ajgasgas
def
alfnasdf
---------------------------------
"abc" and "def" are username and rest two in 2nd and 4th line is respective passwords.
I want to read this data file and authenticate the login through a simple web-page in which javascript is used.

So, please let me know how to do it... Please if possible discuss it with a code.
Thanks

kaidok

9:49 am on May 14, 2009 (gmt 0)

10+ Year Member



Hi, welcome here:

Passwords in Apache do not work this way:

First, you need to create a plain test passwords file via htpasswd, it's on the bin diectory of apache.

Once created and with the users added yo have to put the following on a <Directory /path/to/be/protected> </Directory> in httpd.conf

AuthType Basic or Digest (needs mod_auth or mod_aut_digest)
AuthName "Restricted Files"
AuthDBMUserFile /usr/local/apache/passwd/passwords (Path to the passwords file)
Require user userName (user you allow the access to if he writes his password accordingly).

This automatically displays a dialog box to enter username and password, I suppose there must be some way in javascript to call that authentication process passing to it the username and password , but that's something I don't know. You also have to take into consideration that the password is saved encrypted.

Hope this helps.

[edited by: kaidok at 10:37 am (utc) on May 14, 2009]

kaidok

9:54 am on May 14, 2009 (gmt 0)

10+ Year Member



Sorry, it's AuthUserFile for plain text passwords.

jdMorgan

2:22 pm on May 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two more points:

1) You can use "Require valid-user" to avoid having to list out each user individually.

2) Authentication and Authorization must not be done on the client side. This provides *zero* security, since anyone who knows Javascript can then easily modify your JS code to return "valid" for *any* username or password. Do not use client-side technology for Auth functions!

Jim

ravi18s

3:27 am on May 15, 2009 (gmt 0)

10+ Year Member



Thanks for your reply...I have now got something to fiddlw with