Skip to content
Snippets Groups Projects
Commit add24fd6 authored by Olav Morken's avatar Olav Morken
Browse files

discopower: Allow configuring of the lifetime of the CDC cookie.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2535 44740490-163a-0410-bde0-09ae8108e29a
parent 5defe2e1
Branches
Tags
No related merge requests found
...@@ -36,6 +36,15 @@ $config = array ( ...@@ -36,6 +36,15 @@ $config = array (
*/ */
'cdc.domain' => NULL, 'cdc.domain' => NULL,
/*
* The lifetime of the common domain cookie, in seconds.
*
* If this is NULL (the default), the common domain cookie will be deleted when the browser closes.
*
* Example: 'cdc.lifetime' => 180*24*60*60, // 180 days.
*/
'cdc.lifetime' => NULL,
); );
?> ?>
...@@ -25,6 +25,15 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { ...@@ -25,6 +25,15 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
private $cdcDomain; private $cdcDomain;
/**
* The lifetime of the CDC cookie, in seconds.
* If set to NULL, it will only be valid until the browser is closed.
*
* @var int|NULL
*/
private $cdcLifetime;
/** /**
* Initializes this discovery service. * Initializes this discovery service.
* *
...@@ -45,6 +54,8 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { ...@@ -45,6 +54,8 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
/* Ensure that the CDC domain starts with a dot ('.') as required by the spec. */ /* Ensure that the CDC domain starts with a dot ('.') as required by the spec. */
$this->cdcDomain = '.' . $this->cdcDomain; $this->cdcDomain = '.' . $this->cdcDomain;
} }
$this->cdcLifetime = $this->discoconfig->getInteger('cdc.lifetime', NULL);
} }
...@@ -291,7 +302,13 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { ...@@ -291,7 +302,13 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
$newCookie = $tmp[1]; $newCookie = $tmp[1];
} }
setcookie('_saml_idp', $newCookie, time() + 180*24*60*60, '/', $this->cdcDomain, TRUE); if ($this->cdcLifetime === NULL) {
$expire = 0;
} else {
$expire = time() + $this->cdcLifetime;
}
setcookie('_saml_idp', $newCookie, $expire, '/', $this->cdcDomain, TRUE);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment