You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tracy12 <j_...@yahoo.com> on 2007/01/11 05:21:05 UTC
Lost ENV variable value .........
Hi,
My objective is to update the REMOTE_USER variable within the perl module
and check whether
it is set in side CGI script by refering to the variable
$ENV{'REMOTE_USER'}.
I was successful setting value withing the module but $ENV{'REMOTE_USER'}
inside the CGI prints nothing (empty). Why does it got removed after the
function and redirection.
My perl module look as follows
sub test_Method {
my $self= shift;
my $r = shift;
my $test_user="444584";
$r->connection->user($test_user);
my $user1 = $r->connection->user;
my $urlNew = "http://localhost/rUser.pl?user=$user1";
##my $urlNew = "http://mail.yahoo.com";
$r->content_type('text/html');
$r->header_out->set(Location => $urlNew);
return Apache2::Const::REDIRECT;
}
my CGI perl script (http://localhost/rUser.pl) prints the REMOTE_USER
variable as follows.
print "value of remote port is ",$ENV{'REMOTE_USER'};
I refer to my perl module from httpd.conf as follows.
<Location /goto1>
SetHandler perl-script
PerlHandler AuthCAS->test_Method
</Location>
I am using mod_perl2.0, can somebody let me know why the REMOTE_USER
variable is missing.
What am I doing wrong.
Thanks,
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8271631
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Robert Landrum <rl...@aol.net>.
Tracy12 wrote:
> Thanks,
>
> If this is the case, How can we preserve the REMOTE_USER value and
> forward/redirect to the other application
> ( running on same Apache Server) which is based on the REMOTE_USER
> environment variable, which is set in my perl module in the first
> application.
>
>
> I was under the impression $ENV{'REMOTE_USER') variable can be used for such
> purposes.
I think you've got this idea or notion that this is the right way to do
whatever it is you're trying to do and are asking questions that don't
really make sense to us.
Maybe we could help more if we knew what it was you were really trying
to do.
But if thats not an option... If I wanted to get remote user from one
request to the next, I would pass it as a URL parameter. Something like
/cgi/rUser.pl?remote_user=foobar&other=options
Your other option is to set a cookie containing this user id, or if
security is an issue, use a session, with a unique id for the cookie.
Rob
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
I agree but look at the following scenario
if User hits http://somedomain/test.pl?param1=x¶m2=y
and if a failure happens in the authenticate handler I need to redirect to
http://casmachine:8443/cas/login?service=<above url> that is
http://casmachine:8443/cas/login?service=http://somedomain/test.pl?param1=x¶m2=y
even though the
http://casmachine:8443/cas/login?service=http://somedomain/test.pl is static
users might requrest for inner files. Hence it is not static
Due to this reason I thought I cant use AUTH_REQUIRED and use ErrorDocument
Please let me know above can be achieved even using errorDocument
Thanks
Michael Peters wrote:
>
> Tracy12 wrote:
>
>> 1) As we dont use the apache basic authentication but our CAS
>> authentication. If the authentication is not successful how can we
>> redirect
>> to the CAS login page.
>>
>> My suggestion -> instead of returning the AUTH_REQUIRED redirect to
>> CAS URL with the service.
>> if this is wrong how to achieve this in a different way
>
> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
> redirection
> (unless of course you need to figure out the URL dynamically). This way
> you can
> keep the location as part of your config data.
>
> ErrorDocument 403 /login/url
>
>> 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> entry what the values should we give for AuthType , AuthName in the above
>> Location declaration.
>
> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
> whatever you want it to be. It's basically a way to group the locations
> that use
> the same Auth together (called a "realm").
>
>> 3) Pass addtional parameters to the handler
>> solution -> in the httpd.conf block pass it as
>>
>> PerlSetVar CASHost "testCasServer"
>> PerlSetVar CASPort "8443"
>
> Yep. If possible keep the configuration data inside the configuration
> <Location>s.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8365219
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
I agree but look at the following scenario
if User hits http://somedomain/test.pl?param1=x¶m2=y
and if a failure happens in the authenticate handler I need to redirect to
http://casmachine:8443/cas/login?service=<above url> that is
http://casmachine:8443/cas/login?service=http://somedomain/test.pl?param1=x¶m2=y
even though the
http://casmachine:8443/cas/login?service=http://somedomain/test.pl is static
users might requrest for inner files. Hence it is not static
Due to this reason I thought I cant use AUTH_REQUIRED and use ErrorDocument
Please let me know above can be achieved even using errorDocument
Thanks
Peter Rosenthal wrote:
>
> I have used CAS myself, but instead of attempting to implement the server
> module for CAS authentication I used mod_cas. This might be an easier way
> of
> doing what you are trying to do.
>
> On 12/01/07, Michael Peters <mp...@plusthree.com> wrote:
>>
>> Tracy12 wrote:
>>
>> > 1) As we dont use the apache basic authentication but our CAS
>> > authentication. If the authentication is not successful how can we
>> redirect
>> > to the CAS login page.
>> >
>> > My suggestion -> instead of returning the AUTH_REQUIRED redirect
>> to
>> > CAS URL with the service.
>> > if this is wrong how to achieve this in a different way
>>
>> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
>> redirection
>> (unless of course you need to figure out the URL dynamically). This way
>> you can
>> keep the location as part of your config data.
>>
>> ErrorDocument 403 /login/url
>>
>> > 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> > entry what the values should we give for AuthType , AuthName in the
>> above
>> > Location declaration.
>>
>> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
>> whatever you want it to be. It's basically a way to group the locations
>> that use
>> the same Auth together (called a "realm").
>>
>> > 3) Pass addtional parameters to the handler
>> > solution -> in the httpd.conf block pass it as
>> >
>> > PerlSetVar CASHost "testCasServer"
>> > PerlSetVar CASPort "8443"
>>
>> Yep. If possible keep the configuration data inside the configuration
>> <Location>s.
>>
>> --
>> Michael Peters
>> Developer
>> Plus Three, LP
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8365208
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
Can you let us know how you did this,
Can we update the REMOTE_USER variable, From where can we find the
documentation.
Does mod_cas takes configurable parameters,is it s Authentication module,
Our objective is simply, call the CAS, serivice_validate retrive the xml and
look for a specific attribute, if it is there update the remote_user
variable, that is it. We dont bother about any PGTIOU etc....... We only
care about service_validate.
Let us know specifics,
Thanks
Peter Rosenthal wrote:
>
> I have used CAS myself, but instead of attempting to implement the server
> module for CAS authentication I used mod_cas. This might be an easier way
> of
> doing what you are trying to do.
>
> On 12/01/07, Michael Peters <mp...@plusthree.com> wrote:
>>
>> Tracy12 wrote:
>>
>> > 1) As we dont use the apache basic authentication but our CAS
>> > authentication. If the authentication is not successful how can we
>> redirect
>> > to the CAS login page.
>> >
>> > My suggestion -> instead of returning the AUTH_REQUIRED redirect
>> to
>> > CAS URL with the service.
>> > if this is wrong how to achieve this in a different way
>>
>> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
>> redirection
>> (unless of course you need to figure out the URL dynamically). This way
>> you can
>> keep the location as part of your config data.
>>
>> ErrorDocument 403 /login/url
>>
>> > 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> > entry what the values should we give for AuthType , AuthName in the
>> above
>> > Location declaration.
>>
>> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
>> whatever you want it to be. It's basically a way to group the locations
>> that use
>> the same Auth together (called a "realm").
>>
>> > 3) Pass addtional parameters to the handler
>> > solution -> in the httpd.conf block pass it as
>> >
>> > PerlSetVar CASHost "testCasServer"
>> > PerlSetVar CASPort "8443"
>>
>> Yep. If possible keep the configuration data inside the configuration
>> <Location>s.
>>
>> --
>> Michael Peters
>> Developer
>> Plus Three, LP
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8364005
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Peter Rosenthal <vo...@gmail.com>.
I have used CAS myself, but instead of attempting to implement the server
module for CAS authentication I used mod_cas. This might be an easier way of
doing what you are trying to do.
On 12/01/07, Michael Peters <mp...@plusthree.com> wrote:
>
> Tracy12 wrote:
>
> > 1) As we dont use the apache basic authentication but our CAS
> > authentication. If the authentication is not successful how can we
> redirect
> > to the CAS login page.
> >
> > My suggestion -> instead of returning the AUTH_REQUIRED redirect
> to
> > CAS URL with the service.
> > if this is wrong how to achieve this in a different way
>
> I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the
> redirection
> (unless of course you need to figure out the URL dynamically). This way
> you can
> keep the location as part of your config data.
>
> ErrorDocument 403 /login/url
>
> > 2) As we dont use the basic authentication in apache in the above
> httpd.conf
> > entry what the values should we give for AuthType , AuthName in the
> above
> > Location declaration.
>
> Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
> whatever you want it to be. It's basically a way to group the locations
> that use
> the same Auth together (called a "realm").
>
> > 3) Pass addtional parameters to the handler
> > solution -> in the httpd.conf block pass it as
> >
> > PerlSetVar CASHost "testCasServer"
> > PerlSetVar CASPort "8443"
>
> Yep. If possible keep the configuration data inside the configuration
> <Location>s.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>
>
Re: Lost ENV variable value .........
Posted by Michael Peters <mp...@plusthree.com>.
Tracy12 wrote:
> 1) As we dont use the apache basic authentication but our CAS
> authentication. If the authentication is not successful how can we redirect
> to the CAS login page.
>
> My suggestion -> instead of returning the AUTH_REQUIRED redirect to
> CAS URL with the service.
> if this is wrong how to achieve this in a different way
I'd still use AUTH_REQUIRED and then use ErrorDocument to handle the redirection
(unless of course you need to figure out the URL dynamically). This way you can
keep the location as part of your config data.
ErrorDocument 403 /login/url
> 2) As we dont use the basic authentication in apache in the above httpd.conf
> entry what the values should we give for AuthType , AuthName in the above
> Location declaration.
Set AuthType to 'Basic' since it's not 'Digest'. And then AuthName can be
whatever you want it to be. It's basically a way to group the locations that use
the same Auth together (called a "realm").
> 3) Pass addtional parameters to the handler
> solution -> in the httpd.conf block pass it as
>
> PerlSetVar CASHost "testCasServer"
> PerlSetVar CASPort "8443"
Yep. If possible keep the configuration data inside the configuration <Location>s.
--
Michael Peters
Developer
Plus Three, LP
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
I could overcome the problem by having PerlOptions +GlobalRequest
in the httpd.conf
Also I could get the REMOTE_USER as well.
Let me know if need further information on this.
Thanks
Tracy12 wrote:
>
> Yes CAS CAS authentication is done via a webform, it is working fine.
>
> I already started coding what we discussed, but came up with this error, I
> am using Apache 2.2 with mod_perl2.0
>
> In the log it says that Global $r object is not available.
>
> My perl auth handler looks as follows
>
> sub authen_handler {
> my $self= shift;
> my $r = shift;
> my $user = '123';// WILL BE REPLACED MY CAS VERFICATION, DUMMY
> ONLY
>
> # update connection record
> $r->connection->user($user);
>
> return Apache2::Const::OK;
>
> }
>
> But if we define the handler as PerlHandler $r is available
>
> my httpd.conf looks as follows
>
> <Location /secure>
> AuthType CAS
> AuthName "AuthCAS"
> PerlAuthenHandler AuthCAS->authen_handler
> Require valid-user
> </Location>
>
>
>
> Robert Landrum wrote:
>>
>> Tracy12 wrote:
>>> 1) As we dont use the apache basic authentication but our CAS
>>> authentication. If the authentication is not successful how can we
>>> redirect
>>> to the CAS login page.
>>>
>>
>> Ah-ha... So CAS authentication is done via a webform of some type,
>> which means that it uses cookies. Am I correct in this?
>>
>> I'm not positive about this, but I think you probably want a
>> PerlAuthzHandler instead. In this handler you would confirm that the
>> user is logged into the CAS system, set the REMOTE_USER environment
>> variable, and return OK. If the user wasn't logged in, then you'd
>> redirect to the CAS login page.
>>
>>
>>> 2) As we dont use the basic authentication in apache in the above
>>> httpd.conf
>>> entry what the values should we give for AuthType , AuthName in the
>>> above
>>> Location declaration.
>>>
>>
>> I think, with PerlAuthzHandler you only need to specify a "Requires
>> valid-user" to make it work.
>>
>> Rob
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8292743
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
Yes CAS CAS authentication is done via a webform, it is working fine.
I already started coding what we discussed, but came up with this error, I
am using Apache 2.2 with mod_perl2.0
In the log it says that Global $r object is not available.
My perl auth handler looks as follows
sub authen_handler {
my $self= shift;
my $r = shift;
my $user = '123';// WILL BE REPLACED MY CAS VERFICATION, DUMMY ONLY
# update connection record
$r->connection->user($user);
return Apache2::Const::OK;
}
But if we define the handler as PerlHandler $r is available
my httpd.conf looks as follows
<Location /secure>
AuthType CAS
AuthName "AuthCAS"
PerlAuthenHandler AuthCAS->authen_handler
Require valid-user
</Location>
Robert Landrum wrote:
>
> Tracy12 wrote:
>> 1) As we dont use the apache basic authentication but our CAS
>> authentication. If the authentication is not successful how can we
>> redirect
>> to the CAS login page.
>>
>
> Ah-ha... So CAS authentication is done via a webform of some type,
> which means that it uses cookies. Am I correct in this?
>
> I'm not positive about this, but I think you probably want a
> PerlAuthzHandler instead. In this handler you would confirm that the
> user is logged into the CAS system, set the REMOTE_USER environment
> variable, and return OK. If the user wasn't logged in, then you'd
> redirect to the CAS login page.
>
>
>> 2) As we dont use the basic authentication in apache in the above
>> httpd.conf
>> entry what the values should we give for AuthType , AuthName in the above
>> Location declaration.
>>
>
> I think, with PerlAuthzHandler you only need to specify a "Requires
> valid-user" to make it work.
>
> Rob
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8290672
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Robert Landrum <rl...@aol.net>.
Tracy12 wrote:
> 1) As we dont use the apache basic authentication but our CAS
> authentication. If the authentication is not successful how can we redirect
> to the CAS login page.
>
Ah-ha... So CAS authentication is done via a webform of some type,
which means that it uses cookies. Am I correct in this?
I'm not positive about this, but I think you probably want a
PerlAuthzHandler instead. In this handler you would confirm that the
user is logged into the CAS system, set the REMOTE_USER environment
variable, and return OK. If the user wasn't logged in, then you'd
redirect to the CAS login page.
> 2) As we dont use the basic authentication in apache in the above httpd.conf
> entry what the values should we give for AuthType , AuthName in the above
> Location declaration.
>
I think, with PerlAuthzHandler you only need to specify a "Requires
valid-user" to make it work.
Rob
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
Thanks Perrin and Rob,
Let me summarise what I have gathered from the responses that you all have
provided also with my little knowledge about mod_perl/apache2
Instead of writing a PerlHandler and redirecting to a particular URL, we
should write a PerlAuthenHandler
e.g httpd.conf should be something like this.
<Location /privateUrl>
AuthType AuthCAS
AuthName CAS
PerlAuthenHandler AuthCAS->test_Method
Require valid-user
</Location>
inside the test_Method I need to do my customize authentication check (with
CAS) and update the remote_user variable(e.g $r->connection->user($user1))
and if success return the OK or else return AUTH_REQUIRED.
The application in /privateUrl is a Vendor application, is a complete black
box for us. As part of this integration(Casification) Vendor asked us to do
the authentication (CAS) and if success update the remote user env variable.
Apart from CAS server everything else running on same apache server.
Following are the further little doubts that we have also have given our
suggestion as well, pls do comment on that
1) As we dont use the apache basic authentication but our CAS
authentication. If the authentication is not successful how can we redirect
to the CAS login page.
My suggestion -> instead of returning the AUTH_REQUIRED redirect to
CAS URL with the service.
if this is wrong how to achieve this in a different way
2) As we dont use the basic authentication in apache in the above httpd.conf
entry what the values should we give for AuthType , AuthName in the above
Location declaration.
3) Pass addtional parameters to the handler
solution -> in the httpd.conf block pass it as
PerlSetVar CASHost "testCasServer"
PerlSetVar CASPort "8443"
Please let us know if futher things needs to be done to achieve our
objective
Thanks
Robert Landrum wrote:
>
> Perrin Harkins wrote:
>>> After successful authentication we need to pass the
>>> control to another application(which is running on the same apache
>>> server)
>>> which depend on the REMOTE_USER value which we set.
>>
>> That will work fine, as long as your auth handler runs in the same
>> request as the thing that wants to look at REMOTE_USER. If you do an
>> external redirect, that creates a totally separate request from the
>> client. You need to set your handler as the auth handler for the
>> location that you want to protect, not go the auth handler and then
>> redirect to the location.
>>
>
> I think what Perrin is saying is that you don't want your authentication
> handler to perform the location redirect. In fact, you don't want a
> location redirect at all. You want to return OK if the user is
> authenticated (i.e. the username and passsword are verified by the CAS
> service) and AUTH_REQUIRED otherwise. At least that's how it was in MP1
> and it's probably pretty much the same in MP2.
>
> Rob
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8289722
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Robert Landrum <rl...@aol.net>.
Perrin Harkins wrote:
>> After successful authentication we need to pass the
>> control to another application(which is running on the same apache server)
>> which depend on the REMOTE_USER value which we set.
>
> That will work fine, as long as your auth handler runs in the same
> request as the thing that wants to look at REMOTE_USER. If you do an
> external redirect, that creates a totally separate request from the
> client. You need to set your handler as the auth handler for the
> location that you want to protect, not go the auth handler and then
> redirect to the location.
>
I think what Perrin is saying is that you don't want your authentication
handler to perform the location redirect. In fact, you don't want a
location redirect at all. You want to return OK if the user is
authenticated (i.e. the username and passsword are verified by the CAS
service) and AUTH_REQUIRED otherwise. At least that's how it was in MP1
and it's probably pretty much the same in MP2.
Rob
Re: Lost ENV variable value .........
Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2007-01-11 at 15:01 -0800, Tracy12 wrote:
> My intention is not to use the authentication provided by the apache, but
> uses a authentication mechanism by CAS (Central Autthentication Service)
> running else where
If you intend to use HTTP basic auth (with the popup window that asks
for your login), you still are using apache's auth mechanism. You may
have a custom source for your data, but you still need to follow the
standard auth API.
> After successful authentication we need to pass the
> control to another application(which is running on the same apache server)
> which depend on the REMOTE_USER value which we set.
That will work fine, as long as your auth handler runs in the same
request as the thing that wants to look at REMOTE_USER. If you do an
external redirect, that creates a totally separate request from the
client. You need to set your handler as the auth handler for the
location that you want to protect, not go the auth handler and then
redirect to the location.
> Do you still think we need to pass the value as a cookie, what about the
> security?
Well, basic auth has lousy security. It doesn't encrypt anything, so
it's not secure unless you run over SSL. It is enough for many
applications though.
- Perrin
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
My intention is not to use the authentication provided by the apache, but
uses a authentication mechanism by CAS (Central Autthentication Service)
running else where, After successful authentication we need to pass the
control to another application(which is running on the same apache server)
which depend on the REMOTE_USER value which we set.
Following is the use case.
My ulitmate objective is When a user requests particular service/url (e.g
http://library/service_2), it will be intercepted by Apache2 <Location
/serivice_2> and invoke the perl module which will do a CAS (Central
Authentication Validation) authentication and if success set the REMOTE_USER
value and there after pass the control to (http://library/service_2), This
library serive will retrieve the $ENV{'REMOTE_USER') value and perform
further processing. I have the perl script do the CAS valiation working
fine but still working on the REMOTE_USER variable updation and passing.
Do you still think we need to pass the value as a cookie, what about the
security?, as both the perl module and other other application
(http://library/service_2) resides in the same server on apache server, We
thought REMOTE_USER variable is a handy mechanism to pass the value?
Am I doing something fundamentally wrong?
Perrin Harkins wrote:
>
> On Thu, 2007-01-11 at 14:06 -0800, Tracy12 wrote:
>> If this is the case, How can we preserve the REMOTE_USER value and
>> forward/redirect to the other application
>> ( running on same Apache Server) which is based on the REMOTE_USER
>> environment variable, which is set in my perl module in the first
>> application.
>>
>>
>> I was under the impression $ENV{'REMOTE_USER') variable can be used for
>> such
>> purposes.
>
> It sounds like you're not clear on what HTTP basic authentication does.
> A good starting point is the authentication docs on the apache website:
> http://httpd.apache.org/docs/2.2/howto/auth.html
>
> In short, the server sends a 401 response, the client sends the username
> and password, and that happens on every single request in the realm that
> requires authentication. The REMOTE_USER is just an internal thing to
> see what the auth handler set it to. It's usually the username the
> client sent.
>
> If you're not trying to do authentication and are just looking for a way
> to preserve some data between requests, you need to pass it in cookies,
> or URLs, or hidden form fields.
>
> - Perrin
>
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8288447
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2007-01-11 at 14:06 -0800, Tracy12 wrote:
> If this is the case, How can we preserve the REMOTE_USER value and
> forward/redirect to the other application
> ( running on same Apache Server) which is based on the REMOTE_USER
> environment variable, which is set in my perl module in the first
> application.
>
>
> I was under the impression $ENV{'REMOTE_USER') variable can be used for such
> purposes.
It sounds like you're not clear on what HTTP basic authentication does.
A good starting point is the authentication docs on the apache website:
http://httpd.apache.org/docs/2.2/howto/auth.html
In short, the server sends a 401 response, the client sends the username
and password, and that happens on every single request in the realm that
requires authentication. The REMOTE_USER is just an internal thing to
see what the auth handler set it to. It's usually the username the
client sent.
If you're not trying to do authentication and are just looking for a way
to preserve some data between requests, you need to pass it in cookies,
or URLs, or hidden form fields.
- Perrin
Re: Lost ENV variable value .........
Posted by Tracy12 <j_...@yahoo.com>.
Thanks,
If this is the case, How can we preserve the REMOTE_USER value and
forward/redirect to the other application
( running on same Apache Server) which is based on the REMOTE_USER
environment variable, which is set in my perl module in the first
application.
I was under the impression $ENV{'REMOTE_USER') variable can be used for such
purposes.
Phil Whelan wrote:
>
> Hi Tracy12,
>
>> $r->content_type('text/html');
>> $r->header_out->set(Location => $urlNew);
>> return Apache2::Const::REDIRECT;
>
> When you do the above, you're actually returning context to the
> client, giving them the decision to follow the redirect information or
> not. They most probably will (especially if it's a web browser). All
> server side information will be lost and the User.pl request will be a
> new one.
>
> Cheers,
> Phil
>
>
> On 11/01/07, Tracy12 <j_...@yahoo.com> wrote:
>>
>> Hi,
>>
>> My objective is to update the REMOTE_USER variable within the perl module
>> and check whether
>> it is set in side CGI script by refering to the variable
>> $ENV{'REMOTE_USER'}.
>>
>> I was successful setting value withing the module but $ENV{'REMOTE_USER'}
>> inside the CGI prints nothing (empty). Why does it got removed after the
>> function and redirection.
>>
>> My perl module look as follows
>>
>> sub test_Method {
>> my $self= shift;
>> my $r = shift;
>> my $test_user="444584";
>>
>> $r->connection->user($test_user);
>> my $user1 = $r->connection->user;
>> my $urlNew = "http://localhost/rUser.pl?user=$user1";
>> ##my $urlNew = "http://mail.yahoo.com";
>> $r->content_type('text/html');
>> $r->header_out->set(Location => $urlNew);
>>
>> return Apache2::Const::REDIRECT;
>> }
>>
>> my CGI perl script (http://localhost/rUser.pl) prints the REMOTE_USER
>> variable as follows.
>>
>> print "value of remote port is ",$ENV{'REMOTE_USER'};
>>
>>
>> I refer to my perl module from httpd.conf as follows.
>> <Location /goto1>
>> SetHandler perl-script
>> PerlHandler AuthCAS->test_Method
>> </Location>
>>
>> I am using mod_perl2.0, can somebody let me know why the REMOTE_USER
>> variable is missing.
>>
>> What am I doing wrong.
>>
>> Thanks,
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8271631
>> Sent from the mod_perl - General mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Website: http://philw.co.uk
> Skype: philwhelan76
> UK Mobile: +447968828856
> UK Landline : +441212882897
> Email : phil123@gmail.com
> MSN Messenger : philwhelan66@hotmail.com
> iChat: philwhln@mac.com
>
>
--
View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8286928
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: Lost ENV variable value .........
Posted by Phil Whelan <ph...@gmail.com>.
Hi Tracy12,
> $r->content_type('text/html');
> $r->header_out->set(Location => $urlNew);
> return Apache2::Const::REDIRECT;
When you do the above, you're actually returning context to the
client, giving them the decision to follow the redirect information or
not. They most probably will (especially if it's a web browser). All
server side information will be lost and the User.pl request will be a
new one.
Cheers,
Phil
On 11/01/07, Tracy12 <j_...@yahoo.com> wrote:
>
> Hi,
>
> My objective is to update the REMOTE_USER variable within the perl module
> and check whether
> it is set in side CGI script by refering to the variable
> $ENV{'REMOTE_USER'}.
>
> I was successful setting value withing the module but $ENV{'REMOTE_USER'}
> inside the CGI prints nothing (empty). Why does it got removed after the
> function and redirection.
>
> My perl module look as follows
>
> sub test_Method {
> my $self= shift;
> my $r = shift;
> my $test_user="444584";
>
> $r->connection->user($test_user);
> my $user1 = $r->connection->user;
> my $urlNew = "http://localhost/rUser.pl?user=$user1";
> ##my $urlNew = "http://mail.yahoo.com";
> $r->content_type('text/html');
> $r->header_out->set(Location => $urlNew);
>
> return Apache2::Const::REDIRECT;
> }
>
> my CGI perl script (http://localhost/rUser.pl) prints the REMOTE_USER
> variable as follows.
>
> print "value of remote port is ",$ENV{'REMOTE_USER'};
>
>
> I refer to my perl module from httpd.conf as follows.
> <Location /goto1>
> SetHandler perl-script
> PerlHandler AuthCAS->test_Method
> </Location>
>
> I am using mod_perl2.0, can somebody let me know why the REMOTE_USER
> variable is missing.
>
> What am I doing wrong.
>
> Thanks,
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Lost-ENV-variable-value-.........-tf2956856.html#a8271631
> Sent from the mod_perl - General mailing list archive at Nabble.com.
>
>
--
Website: http://philw.co.uk
Skype: philwhelan76
UK Mobile: +447968828856
UK Landline : +441212882897
Email : phil123@gmail.com
MSN Messenger : philwhelan66@hotmail.com
iChat: philwhln@mac.com