-
Notifications
You must be signed in to change notification settings - Fork 89
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
secureCookie configuration option for cookie secure flag #55
Conversation
Current coverage is 70.71% (diff: 100%)@@ master #55 diff @@
==========================================
Files 2 2
Lines 177 181 +4
Methods 10 10
Messages 0 0
Branches 0 0
==========================================
+ Hits 124 128 +4
Misses 53 53
Partials 0 0
|
@mberkowski could you do minor changes as mentioned in review? so that we could merge & close on this one? |
@mebjas I'm sorry - which changes suggested in review? I have not seen additional comment threads, aside from the code coverage report. I'm unfamiliar with the workflow around codecov.io, if there's a place within it I should be looking for review notes. |
https://github.com/mebjas/CSRF-Protector-PHP/pull/55/files - you'll find review comments here |
Interesting. No PR review comments are visible to me, nor any change requests. Docs suggest anyone with read access can comment, and I have the option to comment myself, but any comments on the PR are not publicly visible or I would have acted on them. |
@mberkowski
Line numbers are according to your push. Hope this workaround works :D |
Apparently review comments don't become public until you hit "submit review" from the green review dropdown. Docs are updated as requested. Sorry I missed the second README in libs/. Regarding the In both cases, the result is the same as before my commit because the PHP defaults are |
@@ -24,6 +24,19 @@ public static function checkHeader($needle) | |||
} | |||
return false; | |||
} | |||
|
|||
public static function getHeaderValue($needle) |
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.
Nice, could you write function documentation for both this one and checkHeader
might come in handy to others. just as brief as testSecureCookie()
one
@@ -325,7 +325,10 @@ public static function refreshToken() | |||
//set token to cookie for client side processing | |||
setcookie(self::$config['CSRFP_TOKEN'], | |||
$token, | |||
time() + self::$cookieExpiryTime); | |||
time() + self::$cookieExpiryTime, | |||
'', |
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.
Leaving empty domain
& path
is standard practice in such cases? when we need to set https only flag?
@@ -19,6 +19,7 @@ | |||
"jsPath" => "../js/csrfprotector.js", | |||
"jsUrl" => "", | |||
"tokenLength" => 10, | |||
"secureCookie" => false, |
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.
Give a description about this field in libs/README.md
Thanks :) |
Related to #54 this adds a configurable option to set a secure cookie flag. In the issue we discussed naming it
httpsOnly
but that may cause confusion with thehttpOnly
cookie option. It is instead namedsecureCookie
but is easily changed.It has been added with a
false
value in the example config, and defaults tofalse
if omitted from the config.Adding a test required also creating a helper method to retrieve header string values to match in assertions. According to the
setcookie()
docs, PHP will only set the secure flag if HTTPS is actually present, so the tests explicitly set$_SERVER['HTTPS'] = on
. Accordingly that has been nulled out in thesetUp()
method.