Re: Perl Authentication Handler and Cookie Issue
Thanks Robert. That did the trick. Sumit Robert Landrum wrote: Sumit Shah wrote: I printed out the contents of the Cookie attribute in the request header and I can see the cookie present in the header. I read all the contents into a hash and then try to check for its existence. The if(exists($hashMap{'SSOTokenID'})) condition fails. Does it have anything to do with data types? How can I check for its existence? Here is the code snippet: my $cookie = $r-headers_in-{'Cookie'}; my @cookieArray = split(;,$cookie); There's your problem... my @coolieArray = split(/\;\s/,$cookie); All of your hash keys will have a space prepended. Rob
Re: Perl Authentication Handler and Cookie Issue
Hello, I have modified my code to handle such scenarios. But the handler still fails to fetch the cookies. The browser does pass the cookies. I can see them in IEHTTPHeaders. I would appreciate if someone could let me know why this could happen? Thanks Sumit Robert Landrum wrote: Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. my $token = $cookies{'SessionID'}-value; chomp($token); $log-error(3. Session ID == $token); You're trying to call a method against a value that may or may not exist. That's a big no-no. if(defined $cookies{'SessionID'}) { $token = $cookies{'SessionID'}-value; } else { $log-error(No SessionID cookie); } Rob
Re: Perl Authentication Handler and Cookie Issue
Hello, I did a small test to see if I can fetch the cookies without using PerlAccessHandler and PerlAuthenHandler. I was able to fetch the cookies using the following directive: FilesMatch \.(html)$ *SetHandler perl-script PerlHandler CAS::SSO */FilesMatch and NOT if I use the following: FilesMatch \.(jsp)$* PerlAccessHandler CAS::SSO *ErrorDocument 403 http://cas.gce2000.com/SecurityServices/JSP/SSOReLogin.jsp /FilesMatch or this: FilesMatch \.(jsp|class)$ *AuthName realm AuthType Basic PerlAuthenHandler CAS::SSO Require valid-user */FilesMatch I would appreciate if someone could tell me the reason for this. Thanks Sumit Sumit Shah wrote: Hello, I have modified my code to handle such scenarios. But the handler still fails to fetch the cookies. The browser does pass the cookies. I can see them in IEHTTPHeaders. I would appreciate if someone could let me know why this could happen? Thanks Sumit Robert Landrum wrote: Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. my $token = $cookies{'SessionID'}-value; chomp($token); $log-error(3. Session ID == $token); You're trying to call a method against a value that may or may not exist. That's a big no-no. if(defined $cookies{'SessionID'}) { $token = $cookies{'SessionID'}-value; } else { $log-error(No SessionID cookie); } Rob
Re: Perl Authentication Handler and Cookie Issue
Sumit, Fetching the cookie has nothing to do with the Perl handlers. They are setting the cookie. You could check this with a small program such as: #!/point/to/your/perl -T include CGI; use vars qw{$query}; # use vars qw{$cookie}; $query = new CGI; $cookie = $query-cookie(YOUR COOKIE NAME) || ; print $query-header(); print cookie was:$cookie; print $query-end_html(); Unfortunately, I'm not familiar with Java JSP, but do a search on 'java cookies' to find out how to read cookies from Java. Rafael On Tue, 2007-02-20 at 11:56 -0500, Sumit Shah wrote: Hello, I did a small test to see if I can fetch the cookies without using PerlAccessHandler and PerlAuthenHandler. I was able to fetch the cookies using the following directive: FilesMatch \.(html)$ *SetHandler perl-script PerlHandler CAS::SSO */FilesMatch and NOT if I use the following: FilesMatch \.(jsp)$* PerlAccessHandler CAS::SSO *ErrorDocument 403 http://cas.gce2000.com/SecurityServices/JSP/SSOReLogin.jsp /FilesMatch or this: FilesMatch \.(jsp|class)$ *AuthName realm AuthType Basic PerlAuthenHandler CAS::SSO Require valid-user */FilesMatch I would appreciate if someone could tell me the reason for this. Thanks Sumit Sumit Shah wrote: Hello, I have modified my code to handle such scenarios. But the handler still fails to fetch the cookies. The browser does pass the cookies. I can see them in IEHTTPHeaders. I would appreciate if someone could let me know why this could happen? Thanks Sumit Robert Landrum wrote: Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. my $token = $cookies{'SessionID'}-value; chomp($token); $log-error(3. Session ID == $token); You're trying to call a method against a value that may or may not exist. That's a big no-no. if(defined $cookies{'SessionID'}) { $token = $cookies{'SessionID'}-value; } else { $log-error(No SessionID cookie); } Rob Analizado por ThMailServer para Linux. !DSPAM:45db27a5188765526914969! Analizado por ThMailServer para Linux.
Re: Perl Authentication Handler and Cookie Issue
On 2/20/07, Sumit Shah [EMAIL PROTECTED] wrote: I did a small test to see if I can fetch the cookies without using PerlAccessHandler and PerlAuthenHandler. So, you're saying that CGI::Cookie works for you from the PerlHandler phase but not from the PerlAccessHandler phase. And I assume you're using mod_perl 1? Are you certain that your handler is running at all when you configure it as a PerlAccessHandler? Make sure that $r you're getting is really an Apache object, and dump the contents of $r-headers_in-{'Cookie'} to see what it's getting. - Perrin
Re: Perl Authentication Handler and Cookie Issue
Thanks. Yes, my handler gets invoked when I set it up as PerlAccessHandler or PerlAuthenHandler but does not fetch any cookies. I am not sure if it has anything to do with the requests (.jsp files) its handling. I will try to dump the headers and see what it gets. Thanks Sumit Perrin Harkins wrote: On 2/20/07, Sumit Shah [EMAIL PROTECTED] wrote: I did a small test to see if I can fetch the cookies without using PerlAccessHandler and PerlAuthenHandler. So, you're saying that CGI::Cookie works for you from the PerlHandler phase but not from the PerlAccessHandler phase. And I assume you're using mod_perl 1? Are you certain that your handler is running at all when you configure it as a PerlAccessHandler? Make sure that $r you're getting is really an Apache object, and dump the contents of $r-headers_in-{'Cookie'} to see what it's getting. - Perrin
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: Thanks. Yes, my handler gets invoked when I set it up as PerlAccessHandler or PerlAuthenHandler but does not fetch any cookies. I am not sure if it has anything to do with the requests (.jsp files) its handling. My guess is that something else is running first and consuming the cookie headers so that later phases don't see them. What else is configured to handle those .jsp pages? -- Michael Peters Developer Plus Three, LP
Re: Perl Authentication Handler and Cookie Issue
The jsp pages are also handled by JSERV. I am not sure if JSERV is kicking in and consuming the headers. Is there a way to check which module is being executed and in what order? Thanks Sumit Michael Peters wrote: Sumit Shah wrote: Thanks. Yes, my handler gets invoked when I set it up as PerlAccessHandler or PerlAuthenHandler but does not fetch any cookies. I am not sure if it has anything to do with the requests (.jsp files) its handling. My guess is that something else is running first and consuming the cookie headers so that later phases don't see them. What else is configured to handle those .jsp pages?
Re: Perl Authentication Handler and Cookie Issue
I printed out the contents of the Cookie attribute in the request header and I can see the cookie present in the header. I read all the contents into a hash and then try to check for its existence. The if(exists($hashMap{'SSOTokenID'})) condition fails. Does it have anything to do with data types? How can I check for its existence? Here is the code snippet: my $cookie = $r-headers_in-{'Cookie'}; my @cookieArray = split(;,$cookie); my %hashMap; my $cookieItem; foreach $cookieItem (@cookieArray){ my @subArray = split(=,$cookieItem); my $key = $subArray[0]; my $value = $subArray[1]; $hashMap{$key}=$value; } my $k; my $v; while ( ($k,$v) = each %hashMap ) { $log-error($k = $v); } my $token; if (exists($hashMap{'SSOTokenID'})) { # it exists $log-error(Token found); $token=$hashMap{'SSOTokenID'}; }else { $log-error(Token NOT Found); } Thanks Sumit Sumit Shah wrote: The jsp pages are also handled by JSERV. I am not sure if JSERV is kicking in and consuming the headers. Is there a way to check which module is being executed and in what order? Thanks Sumit Michael Peters wrote: Sumit Shah wrote: Thanks. Yes, my handler gets invoked when I set it up as PerlAccessHandler or PerlAuthenHandler but does not fetch any cookies. I am not sure if it has anything to do with the requests (.jsp files) its handling. My guess is that something else is running first and consuming the cookie headers so that later phases don't see them. What else is configured to handle those .jsp pages?
Re: Perl Authentication Handler and Cookie Issue
On 2/20/07, Sumit Shah [EMAIL PROTECTED] wrote: I printed out the contents of the Cookie attribute in the request header and I can see the cookie present in the header. I read all the contents into a hash and then try to check for its existence. The if(exists($hashMap{'SSOTokenID'})) condition fails. Does it have anything to do with data types? No, Perl doesn't usually have those kinds of problems. my $cookie = $r-headers_in-{'Cookie'}; my @cookieArray = split(;,$cookie); my %hashMap; my $cookieItem; foreach $cookieItem (@cookieArray){ my @subArray = split(=,$cookieItem); my $key = $subArray[0]; my $value = $subArray[1]; $hashMap{$key}=$value; } my $k; my $v; while ( ($k,$v) = each %hashMap ) { $log-error($k = $v); } What do you see log at this point? A simpler way to dump a hash is like this: use Data::Dumper; warn Dumper(\%hashMap); - Perrin
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: I printed out the contents of the Cookie attribute in the request header and I can see the cookie present in the header. I read all the contents into a hash and then try to check for its existence. The if(exists($hashMap{'SSOTokenID'})) condition fails. Does it have anything to do with data types? How can I check for its existence? Here is the code snippet: my $cookie = $r-headers_in-{'Cookie'}; my @cookieArray = split(;,$cookie); There's your problem... my @coolieArray = split(/\;\s/,$cookie); All of your hash keys will have a space prepended. Rob
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. First thing I'd check is to make sure that the cookies are being sent by the browser. I normally use Firefox and the LiveHTTPHeaders plugin to check that it's sending what I think it should be sending. -- Michael Peters Developer Plus Three, LP
Re: Perl Authentication Handler and Cookie Issue
Yes. I checked that and the browser is sending the cookie. I used IEHTTPHeaders for it. Does it have anything to do with the PerlAuthenHandler that it does not have the cookie at the authentication stage of the request? Does it need anything else to be set in order to fetch the cookies? Thanks Sumit Michael Peters wrote: Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. First thing I'd check is to make sure that the cookies are being sent by the browser. I normally use Firefox and the LiveHTTPHeaders plugin to check that it's sending what I think it should be sending.
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. my $token = $cookies{'SessionID'}-value; chomp($token); $log-error(3. Session ID == $token); You're trying to call a method against a value that may or may not exist. That's a big no-no. if(defined $cookies{'SessionID'}) { $token = $cookies{'SessionID'}-value; } else { $log-error(No SessionID cookie); } Rob