* Allow Cookie option to set secure and HttpOnly flags
PR: 44799
Submitted by: Christian Wenz <christian wenz.org>
Reviewed by: rpluem
* Handle the case that secure is NULL
* Make setting of HttpOnly flag more explicit.
* Allow HttpOnly, 1 and true to enable HttpOnly, allow secure, 1 and true
to enable secure.
Submitted by: rpluem
Reviewed by: jim
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@686789
13f79535-47bb-0310-9956-
ffa450edef68
mod_proxy_ftp: Prevent XSS attacks when using wildcards in the path of
the FTP URL. Discovered by Marc Bevand of Rapid7. [Ruediger Pluem]
+ *) mod_rewrite: Allow Cookie option to set secure and HttpOnly flags.
+ PR 44799 [Christian Wenz <christian wenz.org>]
+
*) mod_ssl: Rewrite shmcb to avoid memory alignment issues. PR 42101.
[Geoff Thorpe]
http://svn.apache.org/viewvc?rev=639010&view=rev (mmn)
+1: niq, rpluem, mturk
- * mod_rewrite: Allow Cookie option to set secure and HttpOnly flags.
- PR 44799
- Trunk version of patch:
- http://svn.apache.org/viewvc?rev=647395&view=rev
- http://svn.apache.org/viewvc?rev=660461&view=rev
- http://svn.apache.org/viewvc?rev=660566&view=rev
- http://svn.apache.org/viewvc?rev=664330&view=rev
- Backport version for 2.2.x of patch:
- Trunk version of patch works
- +1: rpluem, niq, jim
-
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
when you let an external redirect happen (where the
``<code>.www</code>'' part should not occur!).</dd>
- <dt>'<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]'
+ <dt>'<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]]'
(set cookie)</dt><dd>
This sets a cookie in the client's browser. The cookie's name
is specified by <em>NAME</em> and the value is
<em>VAL</em>. The <em>domain</em> field is the domain of the
cookie, such as '.apache.org', the optional <em>lifetime</em>
- is the lifetime of the cookie in minutes, and the optional
- <em>path</em> is the path of the cookie</dd>
+ is the lifetime of the cookie in minutes, and the optional
+ <em>path</em> is the path of the cookie. If <em>secure</em>
+ is set to 'secure', 'true' or '1', the cookie is only transmitted via secured
+ connections. If <em>httponly</em> is set to 'HttpOnly', 'true' or '1', the
+ <code>HttpOnly</code> flag is used, making the cookie not accessible
+ to JavaScript code on browsers that support this feature.</dd>
<dt>
'<code>env|E=</code><em>VAR</em>:<em>VAL</em>'
char *domain;
char *expires;
char *path;
+ char *secure;
+ char *httponly;
char *tok_cntx;
char *cookie;
expires = apr_strtok(NULL, ":", &tok_cntx);
path = expires ? apr_strtok(NULL, ":", &tok_cntx) : NULL;
+ secure = path ? apr_strtok(NULL, ":", &tok_cntx) : NULL;
+ httponly = secure ? apr_strtok(NULL, ":", &tok_cntx) : NULL;
if (expires) {
apr_time_exp_t tms;
"; domain=", domain,
expires ? "; expires=" : NULL,
expires ? exp_time : NULL,
+ (secure && (!strcasecmp(secure, "true")
+ || !strcmp(secure, "1")
+ || !strcasecmp(secure,
+ "secure"))) ?
+ "; secure" : NULL,
+ (httponly && (!strcasecmp(httponly, "true")
+ || !strcmp(httponly, "1")
+ || !strcasecmp(httponly,
+ "HttpOnly"))) ?
+ "; HttpOnly" : NULL,
NULL);
apr_table_addn(rmain->err_headers_out, "Set-Cookie", cookie);