Can PHP exec Apache (.htaccess) user/password authentication?

This is a discussion on Can PHP exec Apache (.htaccess) user/password authentication? within the PHP General forums, part of the PHP Programming Forums category; I have a web site where web pages are set-up for clients to be able to download project files. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-28-2005
eastcoastguyz
 
Posts: n/a
Default Can PHP exec Apache (.htaccess) user/password authentication?

I have a web site where web pages are set-up for clients to be able to
download project files. I'm doing this now with .htaccess and each user
has their own directory. So the user is given their user name/password
and the url for their web page (http://www.domain.com/username) Their
own web page comes up with their name on it and it lists their files.

OK, I was asked, "Why not just have a Login page, and the users enter
in their user name and password which takes them to the directory
already set-up for them now?" That sounds like a reasonable request.

Is there a way to request this from the user through PHP and then pass
it on to Apache's .htaccess for that user's directory to take care of
the authentication? In other words, as if they typed in the url
((http://www.domain.com/username) and logged in directly?

I hope my posting is clear. If not please ask questions, and of course,
be kind. ;-) Thanks!

Reply With Quote
  #2 (permalink)  
Old 11-29-2005
Justin Koivisto
 
Posts: n/a
Default Re: Can PHP exec Apache (.htaccess) user/password authentication?

eastcoastguyz wrote:
> I have a web site where web pages are set-up for clients to be able to
> download project files. I'm doing this now with .htaccess and each user
> has their own directory. So the user is given their user name/password
> and the url for their web page (http://www.domain.com/username) Their
> own web page comes up with their name on it and it lists their files.
>
> OK, I was asked, "Why not just have a Login page, and the users enter
> in their user name and password which takes them to the directory
> already set-up for them now?" That sounds like a reasonable request.
>
> Is there a way to request this from the user through PHP and then pass
> it on to Apache's .htaccess for that user's directory to take care of
> the authentication? In other words, as if they typed in the url
> ((http://www.domain.com/username) and logged in directly?
>
> I hope my posting is clear. If not please ask questions, and of course,
> be kind. ;-) Thanks!
>


HTTP Authentication:
http://us2.php.net/features.http-auth

Say example.com/account/ is protected with Basic Auth.

When the user attempts to access, they need to enter in their user/pass
to gain access. In the directory index page (index.php for this
example), you simply need to check the $_SERVER['PHP_AUTH_USER']
variable for the username that they entered. Then you can redirect to
(or better yet, display) the content that user should see.

HTH

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
Reply With Quote
  #3 (permalink)  
Old 11-29-2005
eastcoastguyz
 
Posts: n/a
Default Re: Can PHP exec Apache (.htaccess) user/password authentication?

Justin Koivisto wrote:
> eastcoastguyz wrote:
> > I have a web site where web pages are set-up for clients to be able to
> > download project files. I'm doing this now with .htaccess and each user
> > has their own directory. So the user is given their user name/password
> > and the url for their web page (http://www.domain.com/username) Their
> > own web page comes up with their name on it and it lists their files.
> >
> > OK, I was asked, "Why not just have a Login page, and the users enter
> > in their user name and password which takes them to the directory
> > already set-up for them now?" That sounds like a reasonable request.
> >
> > Is there a way to request this from the user through PHP and then pass
> > it on to Apache's .htaccess for that user's directory to take care of
> > the authentication? In other words, as if they typed in the url
> > ((http://www.domain.com/username) and logged in directly?
> >
> > I hope my posting is clear. If not please ask questions, and of course,
> > be kind. ;-) Thanks!
> >

>
> HTTP Authentication:
> http://us2.php.net/features.http-auth
>
> Say example.com/account/ is protected with Basic Auth.
>
> When the user attempts to access, they need to enter in their user/pass
> to gain access. In the directory index page (index.php for this
> example), you simply need to check the $_SERVER['PHP_AUTH_USER']
> variable for the username that they entered. Then you can redirect to
> (or better yet, display) the content that user should see.
>
> HTH
>
> --
> Justin Koivisto, ZCE - justin@koivi.com
> http://koivi.com


Thanks for the reply. How does the PHP collecting their username and
password get passed on so that Apache can perform Basic Auth?

Also, I wasn't able to get those code examples in
http://us2.php.net/features.http-auth to work. Do you know of a working
example of this I could download? Thank you!

Reply With Quote
  #4 (permalink)  
Old 11-30-2005
Justin Koivisto
 
Posts: n/a
Default Re: Can PHP exec Apache (.htaccess) user/password authentication?

eastcoastguyz wrote:
> Justin Koivisto wrote:
>
>>eastcoastguyz wrote:
>>
>>>I have a web site where web pages are set-up for clients to be able to
>>>download project files. I'm doing this now with .htaccess and each user
>>>has their own directory. So the user is given their user name/password
>>>and the url for their web page (http://www.domain.com/username) Their
>>>own web page comes up with their name on it and it lists their files.
>>>
>>>OK, I was asked, "Why not just have a Login page, and the users enter
>>>in their user name and password which takes them to the directory
>>>already set-up for them now?" That sounds like a reasonable request.
>>>
>>>Is there a way to request this from the user through PHP and then pass
>>>it on to Apache's .htaccess for that user's directory to take care of
>>>the authentication? In other words, as if they typed in the url
>>>((http://www.domain.com/username) and logged in directly?
>>>
>>>I hope my posting is clear. If not please ask questions, and of course,
>>>be kind. ;-) Thanks!
>>>

>>
>>HTTP Authentication:
>>http://us2.php.net/features.http-auth
>>
>>Say example.com/account/ is protected with Basic Auth.
>>
>>When the user attempts to access, they need to enter in their user/pass
>>to gain access. In the directory index page (index.php for this
>>example), you simply need to check the $_SERVER['PHP_AUTH_USER']
>>variable for the username that they entered. Then you can redirect to
>>(or better yet, display) the content that user should see.

>
> Thanks for the reply. How does the PHP collecting their username and
> password get passed on so that Apache can perform Basic Auth?
>
> Also, I wasn't able to get those code examples in
> http://us2.php.net/features.http-auth to work. Do you know of a working
> example of this I could download? Thank you!


Check this out: http://www.zend.com/zend/tut/authentication.php

Also:
http://koivi.com/php-http-auth/protect.php
user: testing
pass: tester

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0