Skip to content

Commit 6e1e316

Browse files
committed
Add some documentation about remember me, and domain
1 parent ee3083b commit 6e1e316

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

app/sprinkles/account/config/default.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,37 @@
5555
* RememberMe Package Settings
5656
* ----------------------------------------------------------------------
5757
* See https://github.com/gbirke/rememberme for an explanation of these settings
58+
*
59+
* Note that the 'domain' field can be set to match your top-level-domain if you
60+
* want to send the rememberme to all hosts in your domain. An automatic config
61+
* of this can be done in your config.php with code similar to this:
62+
*
63+
* if (!empty($_SERVER['SERVER_NAME']) && filter_var($_SERVER['SERVER_NAME'], \FILTER_VALIDATE_IP) === false) {
64+
* $darr = explode(".", $_SERVER['SERVER_NAME']);
65+
* array_shift($darr);
66+
* $conf['session']['cookie_parameters'] = [ "lifetime" => 86400, "domain" => ".".join(".", $darr), "path" => "/" ];
67+
* $conf['remember_me'] = [ "domain" => ".".join(".", $darr) ];
68+
* }
69+
*
70+
* (Or, for production, you can hard-code the domain rather than calculating it on each page load)
71+
*
72+
* This is DELIBERATELY NOT TURNED ON BY DEFAULT!
73+
*
74+
* If you enable the 'domain' (on both the session and the remember_me cookies)
75+
* you will be sending your authentication cookies to every machine in the
76+
* domain you are using. This may not be bad if you control the domain, but
77+
* if you are using a VPS and the hostname of the machine you are connecting to
78+
* is, for example, host2.vps.blah.com, and you connect to host20.vps.blah.com,
79+
* your browser will send your (super secret) cookies to host20.vps.blah.com.
80+
*
81+
* You only want to turn this on if you want machine1.foo.com to receive the
82+
* cookies that THIS MACHINE (machine2.foo.com) set.
5883
*/
5984
'remember_me' => [
6085
'cookie' => [
6186
'name' => 'rememberme',
6287
],
88+
'domain' => null,
6389
'expire_time' => 604800,
6490
'session' => [
6591
'path' => '/',

app/sprinkles/account/src/Authenticate/Authenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ public function __construct(ClassMapper $classMapper, Session $session, Config $
118118
$this->rememberMe->getCookie()->setPath($this->config['remember_me.session.path']);
119119

120120
// Set expire time, if specified
121-
if ($this->config->has('remember_me.expire_time') && ($this->config->has('remember_me.expire_time') != null)) {
121+
if ($this->config->has('remember_me.expire_time') && $this->config->has('remember_me.expire_time') != null) {
122122
$this->rememberMe->getCookie()->setExpireTime($this->config['remember_me.expire_time']);
123123
}
124124

125125
// Set domain, if specified
126-
if ($this->config->has('remember_me.domain') && ($this->config->has('remember_me.domain') != null)) {
126+
if ($this->config->has('remember_me.domain') && $this->config->has('remember_me.domain') != null) {
127127
$this->rememberMe->getCookie()->setDomain($this->config['remember_me.domain']);
128128
}
129129

0 commit comments

Comments
 (0)