From: <de...@de...> - 2013-06-06 08:39:43
|
Author: MahiroAndo Date: 2013-06-06 03:39:36 -0500 (Thu, 06 Jun 2013) New Revision: 25992 Trac url: http://develop.twiki.org/trac/changeset/25992 Modified: twiki/trunk/SsoForwardCookiePlugin/lib/TWiki/Plugins/SsoForwardCookiePlugin.pm Log: Item7279: Write audit log also when cookie is not forwarded Modified: twiki/trunk/SsoForwardCookiePlugin/lib/TWiki/Plugins/SsoForwardCookiePlugin.pm =================================================================== --- twiki/trunk/SsoForwardCookiePlugin/lib/TWiki/Plugins/SsoForwardCookiePlugin.pm 2013-06-06 08:03:50 UTC (rev 25991) +++ twiki/trunk/SsoForwardCookiePlugin/lib/TWiki/Plugins/SsoForwardCookiePlugin.pm 2013-06-06 08:39:36 UTC (rev 25992) @@ -89,6 +89,7 @@ my $headers = []; my $params = {}; + my $cookieForwarded = 0; $this->writeDebug("Begin hook: $url") if $this->debug; @@ -107,7 +108,8 @@ my $domain = $this->{cookieDomain} || $matchedDomain; my $path = $this->{cookiePath} || '/'; $this->addForwardedCookies($cookieJar, $this->{cookieNames}, $domain, $path); - $this->writeAuditLog($session, $url); + $cookieForwarded = 1; + } else { $this->writeDebug("No cookie names are configured") if $this->debug; } @@ -115,6 +117,10 @@ $this->writeDebug("End hook") if $this->debug; + if (($this->{logging} == 1 && $cookieForwarded) || $this->{logging} == 2) { + $this->writeAuditLog($session, $url, $cookieForwarded); + } + return ($headers, $params); } @@ -161,7 +167,7 @@ cookiePath => $cfg->{CookiePath}, localPattern => (defined $localPattern ? qr{$localPattern} : undef), mdrepoTable => $cfg->{MdrepoTable}, - logging => $cfg->{Logging}, + logging => $cfg->{Logging} || 0, }, $class; if ($this->debug) { @@ -231,26 +237,25 @@ } sub writeAuditLog { - my ($this, $session, $url) = @_; + my ($this, $session, $url, $cookieForwarded) = @_; - if ($this->{logging}) { - # Item7261: $user and/or $wikiName might be undefined - my $wikiName = TWiki::Func::getWikiName(); - my $user = TWiki::Func::wikiToUserName($wikiName) || $wikiName || - 'unknown'; + # Item7261: $user and/or $wikiName might be undefined + my $wikiName = TWiki::Func::getWikiName(); + my $user = TWiki::Func::wikiToUserName($wikiName) || $wikiName || + 'unknown'; - my $web = $session->{SESSION_TAGS}{WEB}; - my $topic = $session->{SESSION_TAGS}{TOPIC}; - my $baseWeb = $session->{SESSION_TAGS}{BASEWEB}; - my $baseTopic = $session->{SESSION_TAGS}{BASETOPIC}; - my $webTopic = "$web.$topic"; + my $web = $session->{SESSION_TAGS}{WEB}; + my $topic = $session->{SESSION_TAGS}{TOPIC}; + my $baseWeb = $session->{SESSION_TAGS}{BASEWEB}; + my $baseTopic = $session->{SESSION_TAGS}{BASETOPIC}; + my $webTopic = "$web.$topic"; - if ("$web.$topic" ne "$baseWeb.$baseTopic") { - $webTopic .= " (base: $baseWeb.$baseTopic)"; - } + if ("$web.$topic" ne "$baseWeb.$baseTopic") { + $webTopic .= " (base: $baseWeb.$baseTopic)"; + } - TWiki::Func::writeDebug("SsoForwardCookiePlugin | $user | $webTopic | $url |"); - } + my $note = $cookieForwarded ? 'FORWARDED' : 'NOT FORWARDED'; + TWiki::Func::writeDebug("SsoForwardCookiePlugin | $user | $webTopic | $url | $note |"); } sub writeWarning { |