[Rt-devel] lib/RT/Interface/Web.pm::Redirect() broken...?
Matthew Sullivan
matthew at sorbs.net
Mon Dec 18 06:26:09 EST 2006
Matthew Sullivan wrote:
> Jesse Vincent wrote:
>> How is that screwing up?
>>
> ended up with: http://rt.sorbs.net:443/....
>
> I'm thinking that the entire rewrite code should be
> "turn-offable"(RT_Config.pm var?) ... It would work fine if I was
> running multiple different servers etc... problem is I'm running one
> server on 2 ports, one ssl and one non ssl ... (it would also be nice to
> tie it into the cookie as well so that the login cookie is valid for
> http and https).
How about this:
--- etc/RT_Config.pm.orig Mon Dec 18 21:16:47 2006
+++ etc/RT_Config.pm Mon Dec 18 20:49:04 2006
@@ -357,6 +357,12 @@
Set($WebNoAuthRegex, qr!^(?:/+NoAuth/|
/+REST/\d+\.\d+/NoAuth/)!x );
+# $MulitportSupport if you run the RT server on more than one port (eg
if you are
+# running RT both SSL'd and non SSL'd for the same server set this to
1) this will
+# stop RT from rewriting the URL upon redirects, default is 0 which
will rewrite
+# URLs and allow RT to run on multiple ports.
+Set($MulitportSupport, 0);
+
# For message boxes, set the entry box width and what type of wrapping
# to use.
#
--- share/html/Elements/SetupSessionCookie.orig Mon Dec 18 20:33:16 2006
+++ share/html/Elements/SetupSessionCookie Mon Dec 18 20:36:27 2006
@@ -47,7 +47,7 @@
return if $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
my %cookies = CGI::Cookie->fetch();
-my $cookiename = "RT_SID_".$RT::rtname.".".$ENV{'SERVER_PORT'};
+my $cookiename = "RT_SID_".$RT::rtname.".".($RT::MulitportSupport ? ""
: $ENV{'SERVER_PORT'});
my %backends = (
mysql => 'Apache::Session::MySQL',
Pg => 'Apache::Session::Postgres',
--- lib/RT/Interface/Web.pm.orig Mon Dec 18 20:42:46 2006
+++ lib/RT/Interface/Web.pm Mon Dec 18 20:42:08 2006
@@ -187,14 +187,18 @@
my $uri = URI->new($redir_to);
my $server_uri = URI->new($RT::WebURL);
- # If the user is coming in via a non-canonical
- # hostname, don't redirect them to the canonical host,
- # it will just upset them (and invalidate their credentials)
- if ($uri->host eq $server_uri->host &&
- $uri->port eq $server_uri->port) {
- $uri->host($ENV{'HTTP_HOST'});
- $uri->port($ENV{'SERVER_PORT'});
- }
+ unless ($RT::MulitportSupport)
+ {
+ # If the user is coming in via a non-canonical
+ # hostname, don't redirect them to the canonical host,
+ # it will just upset them (and invalidate their credentials)
+ if ($uri->host eq $server_uri->host &&
+ $uri->port eq $server_uri->port) {
+ $uri->host($ENV{'HTTP_HOST'});
+ $uri->port($ENV{'SERVER_PORT'});
+ $uri->scheme((exists $ENV{'SCRIPT_URI'} &&
$ENV{'SCRIPT_URI'} =~ /^https:/) ? "https" : "http");
+ }
+ }
$HTML::Mason::Commands::m->redirect($uri->canonical);
$HTML::Mason::Commands::m->abort;
(tested works for me)
Regards
Mat
More information about the Rt-devel
mailing list