Move to PerlSetVar for shared_ses cookie domain
authorJeff Godin <jgodin@tadl.org>
Fri, 12 Oct 2012 14:26:23 +0000 (10:26 -0400)
committerJeff Godin <jgodin@tadl.org>
Fri, 12 Oct 2012 14:26:23 +0000 (10:26 -0400)
Move from SetEnv to PerlSetVar for shared_ses cookie domain, clean
up regex matching of domain.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Open-ILS/examples/apache/eg_vhost.conf
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm

index 81903c9..cb7cffe 100644 (file)
@@ -565,6 +565,10 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT]
     PerlSetVar OILSWebWebDir "/openils/var/web"
     PerlSetVar OILSWebDefaultTemplateExtension "tt2"
 
+    # An optional domain-level cookie "shared_ses" which will contain the
+    # evergreen auth token in addition to the standard "ses" cookie
+    #PerlSetVar OILSWebSharedSesCookieDomain "example.org"
+
     # Enable Template-Toolkit error debugging messages (apache error log)
     PerlSetVar OILSWebDebugTemplate "true"
 
index b477481..45d6ea2 100644 (file)
@@ -436,18 +436,23 @@ sub load_login {
         )
     ];
 
-    if (defined($ENV{shared_ses_domain} && $self->apache->hostname =~ /$ENV{shares_ses_domain}/)) {
-        push @$cookies,
-        # an optional domain-shared copy of the auth token, useful for
-        # some SSO-like environments
-        $cgi->cookie(
-            -name => COOKIE_SHARED_SES,
-            -path => '/',
-            -domain => $ENV{shared_ses_domain},
-            -secure => 1,
-            -value => $response->{payload}->{authtoken},
-            -expires => $login_cookie_expires
-        );
+    if (defined($self->apache->dir_config('OILSWebSharedSesCookieDomain'))) {
+        my $shared_ses_domain = $self->apache->dir_config('OILSWebSharedSesCookieDomain');
+        my $shared_ses_domain_regex = '\.' . $shared_ses_domain . '$';
+
+        if ($self->apache->hostname =~ /$shared_ses_domain_regex/ {
+            push @$cookies,
+            # an optional domain-shared copy of the auth token, useful for
+            # some SSO-like environments
+            $cgi->cookie(
+                -name => COOKIE_SHARED_SES,
+                -path => '/',
+                -domain => $shared_ses_domain,
+                -secure => 1,
+                -value => $response->{payload}->{authtoken},
+                -expires => $login_cookie_expires
+            );
+        }
     }
 
     return $self->generic_redirect(