You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Elam Daly <el...@comcast.net> on 2004/05/25 23:51:30 UTC
[users@httpd] Redirection Based on Authentication
Howdy All,
I'm running Apache 2 on a Redhat box.
I have clients who need to access some files on our webserver. These
files will be placed in directories which will be named after their
login name. Each client will have a username and password, which they
use to login and which will then take them to the relevent directories.
So:
WebRootDir/
login/
client1/
client2/
client3/
etc.
So for instance, client1 logs in, and is taken to the client1 directory.
Now this is the 'solution' I've come up with. I've created a directory
called clients under WebRootDir which I then write a corresponding
Rewrite rule: RewriteRule ^/clients/$ /login/%{LA-U:REMOTE_USER}/ [R]
I then create a login link on the main web page which points to the
client directory and add a .htaccess file to /login, so that when a
client clicks the link they are redirected to the login directory, which
*should* ask for a login name, and then redirect them to the
corresponding directory.
It asks for a username and password and redirects, but not into the
client directory, only into WebRootDir/login/ and I don't know why, so
any help in this area would be appreciated.
Also, what is to stop a client, once they log in, from simply typing a
url so that they can access another clients directory? For instance
client1 typing 'http://login/client2' and viewing the contents of
client2's directory?
If anyone has a more elegant solution, I'm all ears.
Thanks,
Elam Daly
--
' Outward prosperity is a worm at the roots of godliness, so that
religion dies when the world thrives. '
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 26 May 2004, Elam Daly wrote:
>But, this is what you suggested:
>
> RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
>
> I put that in my config file, and requested ' http://localhost:3280/login/ '
> but Mozilla gave me a redirect error and the log dump was huge. I think it
> was telling me that this is a loop, constantly redirecting '/login' requests.
> Did you mean:
>
> RewriteRule ^/clients/?(.*) /login/%{LA-U:REMOTE_USER}/$1
Uh... yah. That's better. (Or else you'd need to put in exclusions for
the case where the username is already there to avoid getting into the
loop.)
>
> Anyway, just to try what I had originally proposed, I correctly requested
> 'http://localhost:3280/clients/ ' with the rewrite rule:
>
> RewriteRule ^/clients/?(.*) /login/%{LA-U:REMOTE_USER} [R]
> [localhost/sid#864c980][rid#870c788/initial] (5) lookahead: path=/clients/
> var=REMOTE_USER -> val=
What do your auth directives look like? Is /clients/ itself protected by
auth in addition to /login/? If not, that is probably your problem.
Protect them both so that the look-ahead on the request to /clients/ will
see a password.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Elam Daly <el...@comcast.net>.
Joshua Slive wrote:
>
> On Wed, 26 May 2004, Elam Daly wrote:
>
>> Joshua Slive wrote:
>>
>>> My suggestion would be to do a transparent (internal) redirect, like
>>> this:
>>>
>>> RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
>
>
>> I set my logging to 9. It seems that the REMOTE_USER variable is
>> being passed correctly, but I end up in WebRootDir/login/ with a
>> directory listing instead of WebRootDir/login/elam/index.html, which
>> does exist. I'm confused by the logging. Why does it keep insisting
>> on serving README.html?
>
>
> README.html/HEADER.html come from the ReadmeName and HeaderName
> directives that determine the files to serve as part of the directory
> index.
>
> The log excerpt that you showed didn't look anything like what you
> described. You must have left off the important part. It looked simply
> like a request for the /login/ directory. Did you try the technique I
> suggested above, where you link directly to /login/ rather than
> bothering with /clients/?
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Hi Josh,
Your right. Too much coffee.
I didn't do as you suggested *yet* as I'm trying to keep it as simple
as possible. But, this is what you suggested:
RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
I put that in my config file, and requested '
http://localhost:3280/login/ ' but Mozilla gave me a redirect error and
the log dump was huge. I think it was telling me that this is a loop,
constantly redirecting '/login' requests. Did you mean:
RewriteRule ^/clients/?(.*) /login/%{LA-U:REMOTE_USER}/$1
Anyway, just to try what I had originally proposed, I correctly
requested 'http://localhost:3280/clients/ ' with the rewrite rule:
RewriteRule ^/clients/?(.*) /login/%{LA-U:REMOTE_USER} [R]
I enter username and password, but still end up in /login directory.
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (2) init rewrite engine
with requested uri /clients/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (3) applying pattern
'^/clients/?(.*)' to uri '/clients/'
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (2) init rewrite engine with
requested uri /clients/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (1) pass through /clients/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#87127a0/subreq] (2) init rewrite engine with
requested uri /clients/index.html
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#87127a0/subreq] (1) pass through
/clients/index.html
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (5) lookahead:
path=/clients/ var=REMOTE_USER -> val=
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (2) rewrite /clients/ ->
/login/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (2) explicitly forcing
redirect with http://localhost:3280/login/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (1) escaping
http://localhost:3280/login/ for redirect
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (1) redirect to
http://localhost:3280/login/ [REDIRECT/302]
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (2) init rewrite engine
with requested uri /login/
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (3) applying pattern
'^/clients/?(.*)' to uri '/login/'
127.0.0.1 - - [26/May/2004:11:27:57 --0400]
[localhost/sid#864c980][rid#870c788/initial] (1) pass through /login/
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#87127a0/initial] (2) init rewrite engine
with requested uri /login/
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#87127a0/initial] (3) applying pattern
'^/clients/?(.*)' to uri '/login/'
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#87127a0/initial] (1) pass through /login/
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (2) init rewrite engine with
requested uri /login/index.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (1) pass through
/login/index.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (2) init rewrite engine with
requested uri /login/HEADER.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#8710798/subreq] (1) pass through
/login/HEADER.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#871d7e8/subreq] (2) init rewrite engine with
requested uri /login/elam/index.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#871d7e8/subreq] (1) pass through
/login/elam/index.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#871b7e0/subreq] (2) init rewrite engine with
requested uri /login/README.html
127.0.0.1 - - [26/May/2004:11:28:00 --0400]
[localhost/sid#864c980][rid#871b7e0/subreq] (1) pass through
/login/README.html
Thanks,
Elam
--
' Outward prosperity is a worm at the roots of godliness, so that
religion dies when the world thrives. '
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Elam Daly <el...@comcast.net>.
Joshua Slive wrote:
> .
>
> The log excerpt that you showed didn't look anything like what you
> described. You must have left off the important part. It looked simply
> like a request for the /login/ directory. Did you try the technique I
> suggested above, where you link directly to /login/ rather than
> bothering with /clients/?
>
> Joshua.
>
Oh man. I double checked and now it works with your redirect rule, no
errors. I don't really understand why, but it does. Why wasn't my
login name being picked up with my rule?
Thanks alot for your help.
Elam
--
' Outward prosperity is a worm at the roots of godliness, so that
religion dies when the world thrives. '
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 26 May 2004, Elam Daly wrote:
> Joshua Slive wrote:
>> My suggestion would be to do a transparent (internal) redirect, like this:
>>
>> RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
> I set my logging to 9. It seems that the REMOTE_USER variable is being
> passed correctly, but I end up in WebRootDir/login/ with a directory listing
> instead of WebRootDir/login/elam/index.html, which does exist. I'm confused
> by the logging. Why does it keep insisting on serving README.html?
README.html/HEADER.html come from the ReadmeName and HeaderName directives
that determine the files to serve as part of the directory index.
The log excerpt that you showed didn't look anything like what you
described. You must have left off the important part. It looked simply
like a request for the /login/ directory. Did you try the technique I
suggested above, where you link directly to /login/ rather than bothering
with /clients/?
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Elam Daly <el...@comcast.net>.
Joshua Slive wrote:
> On Tue, 25 May 2004, Elam Daly wrote:
>
>>Now this is the 'solution' I've come up with. I've created a directory
>>called clients under WebRootDir which I then write a corresponding
>>Rewrite rule: RewriteRule ^/clients/$ /login/%{LA-U:REMOTE_USER}/ [R]
>>
>>I then create a login link on the main web page which points to the
>>client directory and add a .htaccess file to /login, so that when a
>>client clicks the link they are redirected to the login directory, which
>>*should* ask for a login name, and then redirect them to the
>>corresponding directory.
>>
>>It asks for a username and password and redirects, but not into the
>>client directory, only into WebRootDir/login/ and I don't know why, so
>>any help in this area would be appreciated.
>>Also, what is to stop a client, once they log in, from simply typing a
>>url so that they can access another clients directory? For instance
>>client1 typing 'http://login/client2' and viewing the contents of
>>client2's directory?
>
>
> Any time you need to solve a mod_rewrite problem, you should always start
> by turning on the RewriteLog with RewriteLogLevel 9. That will tell you
> what mod_rewrite is seeing.
>
> My suggestion would be to do a transparent (internal) redirect, like this:
>
> RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
>
> This way the clients won't even see that they are in their own directory,
> and they certainly won't be able to get to other people's directories.
>
> Joshua.
>
I set my logging to 9. It seems that the REMOTE_USER variable is being
passed correctly, but I end up in WebRootDir/login/ with a directory
listing instead of WebRootDir/login/elam/index.html, which does exist.
I'm confused by the logging. Why does it keep insisting on serving
README.html?
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#8710790/initial] (2) init rewrite engine
with requested uri /login/
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#8710790/initial] (3) applying pattern
'^/clients/$' to uri '/login/'
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#8710790/initial] (1) pass through /login/
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#871d7e0/subreq] (2) init rewrite engine with
requested uri /login/index.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#871d7e0/subreq] (1) pass through
/login/index.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#871d7e0/subreq] (2) init rewrite engine with
requested uri /login/HEADER.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#871d7e0/subreq] (1) pass through
/login/HEADER.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#870e788/subreq] (2) init rewrite engine with
requested uri /login/elam/index.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#870e788/subreq] (1) pass through
/login/elam/index.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#87197d0/subreq] (2) init rewrite engine with
requested uri /login/README.html
127.0.0.1 - - [26/May/2004:10:16:56 --0400]
[localhost/sid#864c980][rid#87197d0/subreq] (1) pass through
/login/README.html
--
' Outward prosperity is a worm at the roots of godliness, so that
religion dies when the world thrives. '
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirection Based on Authentication
Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 25 May 2004, Elam Daly wrote:
> Now this is the 'solution' I've come up with. I've created a directory
> called clients under WebRootDir which I then write a corresponding
> Rewrite rule: RewriteRule ^/clients/$ /login/%{LA-U:REMOTE_USER}/ [R]
>
> I then create a login link on the main web page which points to the
> client directory and add a .htaccess file to /login, so that when a
> client clicks the link they are redirected to the login directory, which
> *should* ask for a login name, and then redirect them to the
> corresponding directory.
>
> It asks for a username and password and redirects, but not into the
> client directory, only into WebRootDir/login/ and I don't know why, so
> any help in this area would be appreciated.
> Also, what is to stop a client, once they log in, from simply typing a
> url so that they can access another clients directory? For instance
> client1 typing 'http://login/client2' and viewing the contents of
> client2's directory?
Any time you need to solve a mod_rewrite problem, you should always start
by turning on the RewriteLog with RewriteLogLevel 9. That will tell you
what mod_rewrite is seeing.
My suggestion would be to do a transparent (internal) redirect, like this:
RewriteRule ^/login/?(.*) /login/%{LA-U:REMOTE_USER}/$1
This way the clients won't even see that they are in their own directory,
and they certainly won't be able to get to other people's directories.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org