- Added an option to override the session cookie name.
This commit is contained in:
parent
da7dea01f5
commit
2ea58485c9
11 changed files with 40 additions and 28 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
- Added some more tests to the suite.
|
- Added some more tests to the suite.
|
||||||
- Fixed the test skeleton
|
- Fixed the test skeleton
|
||||||
- Fixed some bugs regarding Search relevance sorting (Len Kranendonk / www.ilance.nl)
|
- Fixed some bugs regarding Search relevance sorting (Len Kranendonk / www.ilance.nl)
|
||||||
|
- Added an option to override the session cookie name.
|
||||||
|
|
||||||
|
|
||||||
7.0.4
|
7.0.4
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,12 @@ save you many hours of grief.
|
||||||
released. It will serve as the beta, gamma, and release
|
released. It will serve as the beta, gamma, and release
|
||||||
candidates for 7.0.0.
|
candidates for 7.0.0.
|
||||||
|
|
||||||
|
* The group SQL query mechanism has been changed to be more efficient,
|
||||||
|
more practical, and more consistent with the rest of WebGUI. As
|
||||||
|
such, your old query will no longer work. You used to do something
|
||||||
|
like "select 1 from table where foo='bar'", but now you need to
|
||||||
|
"select userId from table where foo='bar'".
|
||||||
|
|
||||||
* The "messageLog" table will be deleted during the upgrade process,
|
* The "messageLog" table will be deleted during the upgrade process,
|
||||||
and all of the messages in it. This is because the messages
|
and all of the messages in it. This is because the messages
|
||||||
contained in there are no longer useful because they won't
|
contained in there are no longer useful because they won't
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
"sitename" : [ "www.example.com", "example.com"],
|
"sitename" : [ "www.example.com", "example.com"],
|
||||||
|
|
||||||
|
# Rename the WebGUI Session cookie if you like.
|
||||||
|
|
||||||
|
"cookieName" : "wgSession",
|
||||||
|
|
||||||
# The location where the WebGUI server will be handling
|
# The location where the WebGUI server will be handling
|
||||||
# requests. This is normally just '/' or the root of the
|
# requests. This is normally just '/' or the root of the
|
||||||
# server, but on some installations it might be /webgui or
|
# server, but on some installations it might be /webgui or
|
||||||
|
|
|
||||||
|
|
@ -137,19 +137,8 @@ sub addJob {
|
||||||
return 0 unless ($params->{enabled});
|
return 0 unless ($params->{enabled});
|
||||||
my $id = $params->{config}."-".$params->{taskId};
|
my $id = $params->{config}."-".$params->{taskId};
|
||||||
$self->debug("Adding schedule ".$params->{taskId}." to the queue.");
|
$self->debug("Adding schedule ".$params->{taskId}." to the queue.");
|
||||||
$self->{_jobs}{$id} = {
|
$params->{schedule} = join(" ", $params->{minuteOfHour}, $params->{hourOfDay}, $params->{dayOfMonth}, $params->{monthOfYear}, $params->{dayOfWeek});
|
||||||
taskId=>$params->{taskId},
|
$self->{_jobs}{$id} = $params;
|
||||||
config=>$params->{config},
|
|
||||||
gateway=>$params->{gateway},
|
|
||||||
sitename=>$params->{sitename},
|
|
||||||
schedule=>join(" ", $params->{minuteOfHour}, $params->{hourOfDay}, $params->{dayOfMonth}, $params->{monthOfYear}, $params->{dayOfWeek}),
|
|
||||||
runOnce=>$params->{runOnce},
|
|
||||||
workflowId=>$params->{workflowId},
|
|
||||||
className=>$params->{className},
|
|
||||||
methodName=>$params->{methodName},
|
|
||||||
parameters=>$params->{parameters},
|
|
||||||
priority=>$params->{priority}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -400,7 +389,7 @@ sub runJob {
|
||||||
my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").$job->{gateway};
|
my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").$job->{gateway};
|
||||||
my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}];
|
my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}];
|
||||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
$request->header("Cookie",$job->{cookieName}."=".$cookie) if (defined $cookie);
|
||||||
$request->header("User-Agent","Spectre");
|
$request->header("User-Agent","Spectre");
|
||||||
$request->header("X-jobId",$id);
|
$request->header("X-jobId",$id);
|
||||||
$self->debug("Posting job ".$id." to $url.");
|
$self->debug("Posting job ".$id." to $url.");
|
||||||
|
|
@ -431,7 +420,8 @@ sub runJobResponse {
|
||||||
if ($response->header("Set-Cookie") ne "") {
|
if ($response->header("Set-Cookie") ne "") {
|
||||||
$self->debug("Storing cookie for $id for later use.");
|
$self->debug("Storing cookie for $id for later use.");
|
||||||
my $cookie = $response->header("Set-Cookie");
|
my $cookie = $response->header("Set-Cookie");
|
||||||
$cookie =~ s/wgSession=([a-zA-Z0-9\_\-]{22}).*/$1/;
|
my $pattern = $job->{cookieName}."=([a-zA-Z0-9\_\-]{22}).*";
|
||||||
|
$cookie =~ s/$pattern/$1/;
|
||||||
$self->{_cookies}{$job->{sitename}} = $cookie;
|
$self->{_cookies}{$job->{sitename}} = $cookie;
|
||||||
}
|
}
|
||||||
my $state = $response->content;
|
my $state = $response->content;
|
||||||
|
|
|
||||||
|
|
@ -84,13 +84,8 @@ The priority (1,2, or 3) that this instance should be run at.
|
||||||
sub addInstance {
|
sub addInstance {
|
||||||
my ($self, $params) = @_[OBJECT, ARG0];
|
my ($self, $params) = @_[OBJECT, ARG0];
|
||||||
$self->debug("Adding workflow instance ".$params->{instanceId}." from ".$params->{sitename}." to queue at priority ".$params->{priority}.".");
|
$self->debug("Adding workflow instance ".$params->{instanceId}." from ".$params->{sitename}." to queue at priority ".$params->{priority}.".");
|
||||||
$self->{_instances}{$params->{instanceId}} = {
|
$params->{status} = "waiting";
|
||||||
sitename=>$params->{sitename},
|
$self->{_instances}{$params->{instanceId}} = $params;
|
||||||
instanceId=>$params->{instanceId},
|
|
||||||
gateway => $params->{gateway},
|
|
||||||
status=>"waiting",
|
|
||||||
priority=>$params->{priority}
|
|
||||||
};
|
|
||||||
push(@{$self->{"_priority".$params->{priority}}}, $params->{instanceId});
|
push(@{$self->{"_priority".$params->{priority}}}, $params->{instanceId});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +365,7 @@ sub runWorker {
|
||||||
my $url = "http://".$instance->{sitename}.':'.$self->config->get("webguiPort").$instance->{gateway};
|
my $url = "http://".$instance->{sitename}.':'.$self->config->get("webguiPort").$instance->{gateway};
|
||||||
my $request = POST $url, [op=>"runWorkflow", instanceId=>$instance->{instanceId}];
|
my $request = POST $url, [op=>"runWorkflow", instanceId=>$instance->{instanceId}];
|
||||||
my $cookie = $self->{_cookies}{$instance->{sitename}};
|
my $cookie = $self->{_cookies}{$instance->{sitename}};
|
||||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
$request->header("Cookie",$instance->{cookieName}."=".$cookie) if (defined $cookie);
|
||||||
$request->header("X-instanceId",$instance->{instanceId});
|
$request->header("X-instanceId",$instance->{instanceId});
|
||||||
$request->header("User-Agent","Spectre");
|
$request->header("User-Agent","Spectre");
|
||||||
$self->debug("Posting workflow instance ".$instance->{instanceId}." to $url.");
|
$self->debug("Posting workflow instance ".$instance->{instanceId}." to $url.");
|
||||||
|
|
@ -418,7 +413,8 @@ sub workerResponse {
|
||||||
if ($response->header("Set-Cookie") ne "") {
|
if ($response->header("Set-Cookie") ne "") {
|
||||||
$self->debug("Storing cookie for $instanceId for later use.");
|
$self->debug("Storing cookie for $instanceId for later use.");
|
||||||
my $cookie = $response->header("Set-Cookie");
|
my $cookie = $response->header("Set-Cookie");
|
||||||
$cookie =~ s/wgSession=([a-zA-Z0-9\_\-]{22}).*/$1/;
|
my $pattern = $self->{_instances}{$instanceId}{cookieName}."=([a-zA-Z0-9\_\-]{22}).*";
|
||||||
|
$cookie =~ s/$pattern/$1/;
|
||||||
$self->{_cookies}{$self->{_instances}{$instanceId}{sitename}} = $cookie;
|
$self->{_cookies}{$self->{_instances}{$instanceId}{sitename}} = $cookie;
|
||||||
}
|
}
|
||||||
my $state = $response->content;
|
my $state = $response->content;
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ sub contentHandler {
|
||||||
} else {
|
} else {
|
||||||
$output = page($session);
|
$output = page($session);
|
||||||
}
|
}
|
||||||
$session->http->setCookie("wgSession",$session->var->{_var}{sessionId}) unless $session->var->{_var}{sessionId} eq $session->http->getCookies->{"wgSession"};
|
$session->http->setCookie($session->config->getCookieName,$session->var->{_var}{sessionId}) unless $session->var->{_var}{sessionId} eq $session->http->getCookies->{$session->config->getCookieName};
|
||||||
my $filename = $session->http->getStreamedFile();
|
my $filename = $session->http->getStreamedFile();
|
||||||
if ((defined $filename) && ($session->config->get("enableStreamingUploads") eq "1")) {
|
if ((defined $filename) && ($session->config->get("enableStreamingUploads") eq "1")) {
|
||||||
my $ct = guess_media_type($filename);
|
my $ct = guess_media_type($filename);
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,8 @@ sub checkView {
|
||||||
}
|
}
|
||||||
$self->logView();
|
$self->logView();
|
||||||
# must find a way to do this next line better
|
# must find a way to do this next line better
|
||||||
$self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"};
|
my $cookieName = $self->session->config->getCookieName;
|
||||||
|
$self->session->http->setCookie($cookieName,$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{$cookieName};
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,19 @@ sub get {
|
||||||
return $self->{_config}{$param};
|
return $self->{_config}{$param};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getCookieName ( )
|
||||||
|
|
||||||
|
Returns the cookie name defined in the config file. Returns "wgSession" if one isn't defined.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getCookieName {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->get("cookieName") || "wgSession";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ sub open {
|
||||||
my $self = {_config=>$config, _server=>$server};
|
my $self = {_config=>$config, _server=>$server};
|
||||||
bless $self , $class;
|
bless $self , $class;
|
||||||
$self->{_request} = $request if (defined $request);
|
$self->{_request} = $request if (defined $request);
|
||||||
my $sessionId = shift || $self->http->getCookies->{"wgSession"} || $self->id->generate;
|
my $sessionId = shift || $self->http->getCookies->{$config->getCookieName} || $self->id->generate;
|
||||||
$sessionId = $self->id->generate unless $self->id->valid($sessionId);
|
$sessionId = $self->id->generate unless $self->id->valid($sessionId);
|
||||||
my $noFuss = shift;
|
my $noFuss = shift;
|
||||||
$self->{_var} = WebGUI::Session::Var->new($self,$sessionId, $noFuss);
|
$self->{_var} = WebGUI::Session::Var->new($self,$sessionId, $noFuss);
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,7 @@ sub set {
|
||||||
$params{config} = $self->session->config->getFilename;
|
$params{config} = $self->session->config->getFilename;
|
||||||
$params{sitename} = $self->session->config->get("sitename")->[0];
|
$params{sitename} = $self->session->config->get("sitename")->[0];
|
||||||
$params{gateway} = $self->session->config->get("gateway");
|
$params{gateway} = $self->session->config->get("gateway");
|
||||||
|
$params{cookieName} = $self->session->config->getCookieName;
|
||||||
$spectre->notify("cron/addJob", \%params);
|
$spectre->notify("cron/addJob", \%params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ sub set {
|
||||||
if ($properties->{notifySpectre}) {
|
if ($properties->{notifySpectre}) {
|
||||||
my $spectre = WebGUI::Workflow::Spectre->new($self->session);
|
my $spectre = WebGUI::Workflow::Spectre->new($self->session);
|
||||||
$spectre->notify("workflow/deleteInstance",$self->getId) unless ($properties->{newlyCreated});
|
$spectre->notify("workflow/deleteInstance",$self->getId) unless ($properties->{newlyCreated});
|
||||||
$spectre->notify("workflow/addInstance", {gateway=>$self->session->config->get("gateway"), sitename=>$self->session->config->get("sitename")->[0], instanceId=>$self->getId, priority=>$self->{_data}{priority}});
|
$spectre->notify("workflow/addInstance", {cookieName=>$self->session->config->getCookieName, gateway=>$self->session->config->get("gateway"), sitename=>$self->session->config->get("sitename")->[0], instanceId=>$self->getId, priority=>$self->{_data}{priority}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue