Forum Moderators: phranque

Message Too Old, No Replies

Apache Login

how to change the method of logging in

         

znewhsam

7:45 pm on Apr 29, 2006 (gmt 0)

10+ Year Member



Hi, i have set up really basic web server with apache, mainly for integration with a program i have written, this program accesses via the internet media content, launches html files in a browser, i would like the program to send the users login credentials, as they have to login using the program before they can do anything, and it is apparently 'annoying' to have to log in again to access a file. Is there a way of sending user credentials with the page request , something like "http://serveraddress/page/ username:password" or something?

Thanks for your help

znewsham

StupidScript

7:16 pm on May 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard, znewhsam!

Depending on the setup at the receiving end, you can often pass login info using the following syntax:

http://username:password@serveraddress/page/

Hope that does it!

znewhsam

10:27 pm on May 1, 2006 (gmt 0)

10+ Year Member



thanks, but unfortunatley not, i have made a php script that stores username and passwords in cookies, is this what apache uses? or is the message box the only way to login? thanks for your help
znewsham

StupidScript

5:05 pm on May 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Message box? Are you restricting access using .htaccess?

znewhsam

8:38 pm on May 2, 2006 (gmt 0)

10+ Year Member



yeah i am, i thought that was the only was to implement authentication on a whole directory, whilst keeping the directory view, thats what i really need it for, to allow access so a certain user can view the content of a page

StupidScript

7:55 pm on May 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, .htaccess is not the preferred method:

Putting authentication directives in a <Directory> section, in your main server configuration file, is the preferred way to implement this, and .htaccess files should be used only if you don't have access to the main server configuration file.

I think the answer to your question about requiring more than one login can be found in the Apache docs:

[httpd.apache.org...]

(See the "Getting it Working" section and read carefully. It discusses exactly the issue you want to learn about.)

Also see [httpd.apache.org...] for an example of using default password/user files for authentication. (Section "Apache Tutorial: .htaccess files".)

znewhsam

11:22 pm on May 3, 2006 (gmt 0)

10+ Year Member



HI, thanks for the help, but i am not sure that that is the problem, i cant edit the main configuration file because the program creates the .htaccess file automatically and fills it with the correct content. The problem as i see it is, that i can make the .htaccess files work in the directories, however i cant integrate them with any part of my php script, or access the username from cookies, and my php script, which stores usernames and passwords as cookies so that each page can check them, cant integrate with the apache login process, hence, when the user wants to leave a comment, for example, they have to go in using the php script, but when they want to view their directories, they have to log in via the apache message box, iregardless of wether they are already logged in. WHat i think i need to find, is a way of automatically sending the server the username and password of the member, if they are already logged in

thanks, and sorry for the long message
znewsham

StupidScript

6:00 pm on May 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about using PHP for the whole thing, once they use the Apache login for initial access? The major change would be in viewing the contents of a directory, for which you would need to write a little PHP page that grabs the info and displays it.

1) User hits the directory for the first time
2) User logs into the Apache mechanism
3) Credentials stored in a cookie (as I understand it?)
Maybe they also need to log in using PHP ... can't tell how your app works
4) Everything else is authenticated by PHP

Using that type of setup they would only need to log into Apache once, and everything else is handled by PHP authentication based on the cookie data.

The Apache .htaccess login protects raw directory access, but page access is controlled by PHP.

Maybe?

znewhsam

9:25 pm on May 4, 2006 (gmt 0)

10+ Year Member



that could work, get the user to sign in with apache at the main page, however they would still need to sign in with php for the pages, but only once, however apache does 'forget' the credentials once a browser closes. If i could find out what cookies apache uses i could make them co-operate, i will start looking into that now