-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.2] Set HttpOnly flag #12809
Closed
+22
−14
Closed
[5.2] Set HttpOnly flag #12809
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,13 @@ class CookieJar implements JarContract | |
protected $secure = false; | ||
|
||
/** | ||
* The default httpOnly setting (defaults to true). | ||
* | ||
* @var bool | ||
*/ | ||
protected $httpOnly = true; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems to be a TAB issue? |
||
* All of the cookies queued for sending. | ||
* | ||
* @var array | ||
|
@@ -48,9 +55,9 @@ class CookieJar implements JarContract | |
* @param bool $httpOnly | ||
* @return \Symfony\Component\HttpFoundation\Cookie | ||
*/ | ||
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) | ||
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = null) | ||
{ | ||
list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure); | ||
list($path, $domain, $secure, $httpOnly) = $this->getPathAndDomain($path, $domain, $secure, $httpOnly); | ||
|
||
$time = ($minutes == 0) ? 0 : time() + ($minutes * 60); | ||
|
||
|
@@ -68,7 +75,7 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null, | |
* @param bool $httpOnly | ||
* @return \Symfony\Component\HttpFoundation\Cookie | ||
*/ | ||
public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true) | ||
public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = null) | ||
{ | ||
return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly); | ||
} | ||
|
@@ -143,11 +150,12 @@ public function unqueue($name) | |
* @param string $path | ||
* @param string $domain | ||
* @param bool $secure | ||
* @param bool $httpOnly | ||
* @return array | ||
*/ | ||
protected function getPathAndDomain($path, $domain, $secure = false) | ||
protected function getPathAndDomain($path, $domain, $secure = null, $httpOnly = null) | ||
{ | ||
return [$path ?: $this->path, $domain ?: $this->domain, $secure ?: $this->secure]; | ||
return [$path ?: $this->path, $domain ?: $this->domain, isset($secure) ? $secure : $this->secure, isset($httpOnly) ? $httpOnly : $this->httpOnly]; | ||
} | ||
|
||
/** | ||
|
@@ -156,11 +164,12 @@ protected function getPathAndDomain($path, $domain, $secure = false) | |
* @param string $path | ||
* @param string $domain | ||
* @param bool $secure | ||
* @param bool $httpOnly | ||
* @return $this | ||
*/ | ||
public function setDefaultPathAndDomain($path, $domain, $secure = false) | ||
public function setDefaultPathAndDomain($path, $domain, $secure = false, $httpOnly = true) | ||
{ | ||
list($this->path, $this->domain, $this->secure) = [$path, $domain, $secure]; | ||
list($this->path, $this->domain, $this->secure, $this->httpOnly) = [$path, $domain, $secure, $httpOnly]; | ||
|
||
return $this; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ public function register() | |
$this->app->singleton('cookie', function ($app) { | ||
$config = $app['config']['session']; | ||
|
||
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain'], $config['secure']); | ||
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain'], $config['secure'], data_get($config,'http_only',true)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to add an extra spaces here:
|
||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in #12818 (comment)
Making this default to
true
while previously it's default tofalse
in a patch release should be consider as breaking change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value was true, and it can be override by passing another value to make function. Now all we make that we read this value from session config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can you say that when the changelog clearly shows the opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When anyone upgrade from say
v5.2.24
tov5.2.25
(if this get accepted). People shouldn't be worry about any configuration change and everything should works as it was before.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that,s right . I,ll update the cookie service provider file to keep it as previously settings.