Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_userid_filter_module.c @ 8360:98c4020f1c9a quic
HTTP/3: keepalive timeout.
This timeout limits the time when no client request streams exist.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 30 Mar 2021 16:48:38 +0300 |
parents | c0cacad62cc8 |
children | ef6a3a99a81a |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
6 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
13 #define NGX_HTTP_USERID_OFF 0 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
14 #define NGX_HTTP_USERID_LOG 1 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
15 #define NGX_HTTP_USERID_V1 2 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
16 #define NGX_HTTP_USERID_ON 3 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
17 |
8122
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
18 #define NGX_HTTP_USERID_COOKIE_OFF 0x0002 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
19 #define NGX_HTTP_USERID_COOKIE_SECURE 0x0004 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
20 #define NGX_HTTP_USERID_COOKIE_HTTPONLY 0x0008 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
21 #define NGX_HTTP_USERID_COOKIE_SAMESITE 0x0010 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
22 #define NGX_HTTP_USERID_COOKIE_SAMESITE_STRICT 0x0020 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
23 #define NGX_HTTP_USERID_COOKIE_SAMESITE_LAX 0x0040 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
24 #define NGX_HTTP_USERID_COOKIE_SAMESITE_NONE 0x0080 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
25 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
26 /* 31 Dec 2037 23:55:55 GMT */ |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
27 #define NGX_HTTP_USERID_MAX_EXPIRES 2145916555 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 typedef struct { |
509 | 31 ngx_uint_t enable; |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
32 ngx_uint_t flags; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 ngx_int_t service; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 ngx_str_t name; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 ngx_str_t domain; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 ngx_str_t path; |
539 | 39 ngx_str_t p3p; |
40 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 time_t expires; |
539 | 42 |
43 u_char mark; | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 } ngx_http_userid_conf_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 typedef struct { |
461 | 48 uint32_t uid_got[4]; |
49 uint32_t uid_set[4]; | |
539 | 50 ngx_str_t cookie; |
3943 | 51 ngx_uint_t reset; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 } ngx_http_userid_ctx_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
55 static ngx_http_userid_ctx_t *ngx_http_userid_get_uid(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
56 ngx_http_userid_conf_t *conf); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
57 static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
58 ngx_http_variable_value_t *v, ngx_str_t *name, uint32_t *uid); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
59 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, |
499 | 60 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
61 static ngx_int_t ngx_http_userid_create_uid(ngx_http_request_t *r, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
62 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 |
573 | 64 static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf); |
681 | 65 static ngx_int_t ngx_http_userid_init(ngx_conf_t *cf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 static void *ngx_http_userid_create_conf(ngx_conf_t *cf); |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, |
499 | 68 void *child); |
69 static char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data); | |
70 static char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data); | |
71 static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, | |
72 void *conf); | |
73 static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data); | |
539 | 74 static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, |
75 void *conf); | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
76 static ngx_int_t ngx_http_userid_init_worker(ngx_cycle_t *cycle); |
539 | 77 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
80 static uint32_t start_value; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
81 static uint32_t sequencer_v1 = 1; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
82 static uint32_t sequencer_v2 = 0x03030302; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
83 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
84 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
85 static u_char expires[] = "; expires=Thu, 31-Dec-37 23:55:55 GMT"; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
86 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
87 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
88 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
89 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
90 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
91 static ngx_conf_enum_t ngx_http_userid_state[] = { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 { ngx_string("off"), NGX_HTTP_USERID_OFF }, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
93 { ngx_string("log"), NGX_HTTP_USERID_LOG }, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
94 { ngx_string("v1"), NGX_HTTP_USERID_V1 }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 { ngx_string("on"), NGX_HTTP_USERID_ON }, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 { ngx_null_string, 0 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
100 static ngx_conf_bitmask_t ngx_http_userid_flags[] = { |
8122
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
101 { ngx_string("off"), NGX_HTTP_USERID_COOKIE_OFF }, |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
102 { ngx_string("secure"), NGX_HTTP_USERID_COOKIE_SECURE }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
103 { ngx_string("httponly"), NGX_HTTP_USERID_COOKIE_HTTPONLY }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
104 { ngx_string("samesite=strict"), |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
105 NGX_HTTP_USERID_COOKIE_SAMESITE|NGX_HTTP_USERID_COOKIE_SAMESITE_STRICT }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
106 { ngx_string("samesite=lax"), |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
107 NGX_HTTP_USERID_COOKIE_SAMESITE|NGX_HTTP_USERID_COOKIE_SAMESITE_LAX }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
108 { ngx_string("samesite=none"), |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
109 NGX_HTTP_USERID_COOKIE_SAMESITE|NGX_HTTP_USERID_COOKIE_SAMESITE_NONE }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
110 { ngx_null_string, 0 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
111 }; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
112 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
113 |
461 | 114 static ngx_conf_post_handler_pt ngx_http_userid_domain_p = |
509 | 115 ngx_http_userid_domain; |
461 | 116 static ngx_conf_post_handler_pt ngx_http_userid_path_p = ngx_http_userid_path; |
117 static ngx_conf_post_handler_pt ngx_http_userid_p3p_p = ngx_http_userid_p3p; | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
118 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
119 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 static ngx_command_t ngx_http_userid_commands[] = { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 { ngx_string("userid"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
123 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
124 ngx_conf_set_enum_slot, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 offsetof(ngx_http_userid_conf_t, enable), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
127 ngx_http_userid_state }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 { ngx_string("userid_service"), |
539 | 130 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 ngx_conf_set_num_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 offsetof(ngx_http_userid_conf_t, service), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
134 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 { ngx_string("userid_name"), |
539 | 137 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 offsetof(ngx_http_userid_conf_t, name), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
141 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 { ngx_string("userid_domain"), |
539 | 144 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 offsetof(ngx_http_userid_conf_t, domain), |
461 | 148 &ngx_http_userid_domain_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 { ngx_string("userid_path"), |
539 | 151 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 offsetof(ngx_http_userid_conf_t, path), |
461 | 155 &ngx_http_userid_path_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 { ngx_string("userid_expires"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
158 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
159 ngx_http_userid_expires, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 NGX_HTTP_LOC_CONF_OFFSET, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
161 0, |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
162 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
164 { ngx_string("userid_flags"), |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
165 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
166 ngx_conf_set_bitmask_slot, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
167 NGX_HTTP_LOC_CONF_OFFSET, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
168 offsetof(ngx_http_userid_conf_t, flags), |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
169 &ngx_http_userid_flags }, |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
170 |
461 | 171 { ngx_string("userid_p3p"), |
172 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
173 ngx_conf_set_str_slot, | |
174 NGX_HTTP_LOC_CONF_OFFSET, | |
175 offsetof(ngx_http_userid_conf_t, p3p), | |
176 &ngx_http_userid_p3p_p }, | |
177 | |
539 | 178 { ngx_string("userid_mark"), |
179 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
180 ngx_http_userid_mark, | |
181 NGX_HTTP_LOC_CONF_OFFSET, | |
182 0, | |
183 NULL }, | |
184 | |
499 | 185 ngx_null_command |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 |
667 | 189 static ngx_http_module_t ngx_http_userid_filter_module_ctx = { |
573 | 190 ngx_http_userid_add_variables, /* preconfiguration */ |
681 | 191 ngx_http_userid_init, /* postconfiguration */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 NULL, /* create main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 NULL, /* init main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 NULL, /* create server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 NULL, /* merge server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4474
diff
changeset
|
199 ngx_http_userid_create_conf, /* create location configuration */ |
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4474
diff
changeset
|
200 ngx_http_userid_merge_conf /* merge location configuration */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
204 ngx_module_t ngx_http_userid_filter_module = { |
509 | 205 NGX_MODULE_V1, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
206 &ngx_http_userid_filter_module_ctx, /* module context */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 ngx_http_userid_commands, /* module directives */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 NGX_HTTP_MODULE, /* module type */ |
541 | 209 NULL, /* init master */ |
681 | 210 NULL, /* init module */ |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
211 ngx_http_userid_init_worker, /* init process */ |
541 | 212 NULL, /* init thread */ |
213 NULL, /* exit thread */ | |
214 NULL, /* exit process */ | |
215 NULL, /* exit master */ | |
216 NGX_MODULE_V1_PADDING | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
3943 | 220 static ngx_str_t ngx_http_userid_got = ngx_string("uid_got"); |
221 static ngx_str_t ngx_http_userid_set = ngx_string("uid_set"); | |
222 static ngx_str_t ngx_http_userid_reset = ngx_string("uid_reset"); | |
223 static ngx_uint_t ngx_http_userid_reset_index; | |
573 | 224 |
225 | |
499 | 226 static ngx_int_t |
227 ngx_http_userid_filter(ngx_http_request_t *r) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 ngx_http_userid_ctx_t *ctx; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
597 | 232 if (r != r->main) { |
509 | 233 return ngx_http_next_header_filter(r); |
234 } | |
235 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
236 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
237 |
3647 | 238 if (conf->enable < NGX_HTTP_USERID_V1) { |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
239 return ngx_http_next_header_filter(r); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
240 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
242 ctx = ngx_http_userid_get_uid(r, conf); |
499 | 243 |
244 if (ctx == NULL) { | |
245 return NGX_ERROR; | |
246 } | |
247 | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
248 if (ngx_http_userid_set_uid(r, ctx, conf) == NGX_OK) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
249 return ngx_http_next_header_filter(r); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
252 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
253 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
254 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
255 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
256 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
257 ngx_http_userid_got_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
258 ngx_http_variable_value_t *v, uintptr_t data) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
259 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
260 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
261 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
262 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
263 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
264 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
265 if (conf->enable == NGX_HTTP_USERID_OFF) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
266 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
267 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
268 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
269 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
270 ctx = ngx_http_userid_get_uid(r->main, conf); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
271 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
272 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
273 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
274 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
275 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
276 if (ctx->uid_got[3] != 0) { |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
277 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_got); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
278 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
279 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
280 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
281 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
282 return NGX_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
283 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
286 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
287 ngx_http_userid_set_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
288 ngx_http_variable_value_t *v, uintptr_t data) |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
290 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
291 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
292 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
293 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
294 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
295 if (conf->enable < NGX_HTTP_USERID_V1) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
296 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
297 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
298 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
299 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
300 ctx = ngx_http_userid_get_uid(r->main, conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
301 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
302 if (ctx == NULL) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
303 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
304 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
305 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
306 if (ngx_http_userid_create_uid(r->main, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
307 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
308 } |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
309 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
310 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
311 v->not_found = 1; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
312 return NGX_OK; |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
313 } |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
314 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
315 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_set); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
316 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
317 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
318 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
319 static ngx_http_userid_ctx_t * |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
320 ngx_http_userid_get_uid(ngx_http_request_t *r, ngx_http_userid_conf_t *conf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
321 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
322 ngx_int_t n; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
323 ngx_str_t src, dst; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
324 ngx_table_elt_t **cookies; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
325 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
326 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
327 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
328 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
329 if (ctx) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
330 return ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
331 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
332 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
333 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
334 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_userid_ctx_t)); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
335 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
336 return NULL; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
337 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
338 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
339 ngx_http_set_ctx(r, ctx, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
340 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
341 |
509 | 342 n = ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &conf->name, |
539 | 343 &ctx->cookie); |
509 | 344 if (n == NGX_DECLINED) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
345 return ctx; |
509 | 346 } |
461 | 347 |
539 | 348 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
349 "uid cookie: \"%V\"", &ctx->cookie); | |
350 | |
351 if (ctx->cookie.len < 22) { | |
509 | 352 cookies = r->headers_in.cookies.elts; |
353 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
354 "client sent too short userid cookie \"%V\"", | |
355 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
356 return ctx; |
509 | 357 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 |
539 | 359 src = ctx->cookie; |
360 | |
509 | 361 /* |
539 | 362 * we have to limit the encoded string to 22 characters because |
363 * 1) cookie may be marked by "userid_mark", | |
364 * 2) and there are already the millions cookies with a garbage | |
365 * instead of the correct base64 trail "==" | |
509 | 366 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
367 |
509 | 368 src.len = 22; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
369 |
509 | 370 dst.data = (u_char *) ctx->uid_got; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
371 |
509 | 372 if (ngx_decode_base64(&dst, &src) == NGX_ERROR) { |
373 cookies = r->headers_in.cookies.elts; | |
374 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
375 "client sent invalid userid cookie \"%V\"", | |
376 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
377 return ctx; |
509 | 378 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
379 |
509 | 380 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
381 "uid: %08XD%08XD%08XD%08XD", | |
382 ctx->uid_got[0], ctx->uid_got[1], | |
383 ctx->uid_got[2], ctx->uid_got[3]); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
384 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
385 return ctx; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
386 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
387 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
388 |
499 | 389 static ngx_int_t |
390 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | |
391 ngx_http_userid_conf_t *conf) | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
392 { |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
393 u_char *cookie, *p; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
394 size_t len; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
395 ngx_str_t src, dst; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
396 ngx_table_elt_t *set_cookie, *p3p; |
2528 | 397 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
398 if (ngx_http_userid_create_uid(r, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
399 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
400 } |
539 | 401 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
402 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
403 return NGX_OK; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
404 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
405 |
461 | 406 len = conf->name.len + 1 + ngx_base64_encoded_length(16) + conf->path.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
407 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
408 if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
409 len += sizeof(expires) - 1 + 2; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
410 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
411 |
479 | 412 if (conf->domain.len) { |
461 | 413 len += conf->domain.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
414 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
415 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
416 if (conf->flags & NGX_HTTP_USERID_COOKIE_SECURE) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
417 len += sizeof("; secure") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
418 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
419 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
420 if (conf->flags & NGX_HTTP_USERID_COOKIE_HTTPONLY) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
421 len += sizeof("; httponly") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
422 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
423 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
424 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_STRICT) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
425 len += sizeof("; samesite=strict") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
426 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
427 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
428 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_LAX) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
429 len += sizeof("; samesite=lax") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
430 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
431 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
432 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_NONE) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
433 len += sizeof("; samesite=none") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
434 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
435 |
2049 | 436 cookie = ngx_pnalloc(r->pool, len); |
499 | 437 if (cookie == NULL) { |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
438 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
439 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
440 |
573 | 441 p = ngx_copy(cookie, conf->name.data, conf->name.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
442 *p++ = '='; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
443 |
3943 | 444 if (ctx->uid_got[3] == 0 || ctx->reset) { |
539 | 445 src.len = 16; |
446 src.data = (u_char *) ctx->uid_set; | |
447 dst.data = p; | |
448 | |
449 ngx_encode_base64(&dst, &src); | |
450 | |
451 p += dst.len; | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
452 |
539 | 453 if (conf->mark) { |
454 *(p - 2) = conf->mark; | |
455 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
456 |
539 | 457 } else { |
458 p = ngx_cpymem(p, ctx->cookie.data, 22); | |
459 *p++ = conf->mark; | |
460 *p++ = '='; | |
461 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
462 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
463 if (conf->expires == NGX_HTTP_USERID_MAX_EXPIRES) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
464 p = ngx_cpymem(p, expires, sizeof(expires) - 1); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
465 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
466 } else if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
467 p = ngx_cpymem(p, expires, sizeof("; expires=") - 1); |
455 | 468 p = ngx_http_cookie_time(p, ngx_time() + conf->expires); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
469 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
470 |
573 | 471 p = ngx_copy(p, conf->domain.data, conf->domain.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
472 |
573 | 473 p = ngx_copy(p, conf->path.data, conf->path.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
474 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
475 if (conf->flags & NGX_HTTP_USERID_COOKIE_SECURE) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
476 p = ngx_cpymem(p, "; secure", sizeof("; secure") - 1); |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
477 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
478 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
479 if (conf->flags & NGX_HTTP_USERID_COOKIE_HTTPONLY) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
480 p = ngx_cpymem(p, "; httponly", sizeof("; httponly") - 1); |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
481 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
482 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
483 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_STRICT) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
484 p = ngx_cpymem(p, "; samesite=strict", sizeof("; samesite=strict") - 1); |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
485 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
486 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
487 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_LAX) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
488 p = ngx_cpymem(p, "; samesite=lax", sizeof("; samesite=lax") - 1); |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
489 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
490 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
491 if (conf->flags & NGX_HTTP_USERID_COOKIE_SAMESITE_NONE) { |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
492 p = ngx_cpymem(p, "; samesite=none", sizeof("; samesite=none") - 1); |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
493 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
494 |
499 | 495 set_cookie = ngx_list_push(&r->headers_out.headers); |
496 if (set_cookie == NULL) { | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
497 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
498 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
499 |
509 | 500 set_cookie->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
501 ngx_str_set(&set_cookie->key, "Set-Cookie"); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
502 set_cookie->value.len = p - cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
503 set_cookie->value.data = cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
504 |
461 | 505 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
506 "uid cookie: \"%V\"", &set_cookie->value); | |
507 | |
479 | 508 if (conf->p3p.len == 0) { |
461 | 509 return NGX_OK; |
510 } | |
511 | |
499 | 512 p3p = ngx_list_push(&r->headers_out.headers); |
513 if (p3p == NULL) { | |
461 | 514 return NGX_ERROR; |
515 } | |
516 | |
509 | 517 p3p->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
518 ngx_str_set(&p3p->key, "P3P"); |
461 | 519 p3p->value = conf->p3p; |
520 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
521 return NGX_OK; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
522 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
523 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
524 |
499 | 525 static ngx_int_t |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
526 ngx_http_userid_create_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
527 ngx_http_userid_conf_t *conf) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
528 { |
3943 | 529 ngx_connection_t *c; |
530 struct sockaddr_in *sin; | |
531 ngx_http_variable_value_t *vv; | |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
532 #if (NGX_HAVE_INET6) |
3943 | 533 u_char *p; |
534 struct sockaddr_in6 *sin6; | |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
535 #endif |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
536 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
537 if (ctx->uid_set[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
538 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
539 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
540 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
541 if (ctx->uid_got[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
542 |
3943 | 543 vv = ngx_http_get_indexed_variable(r, ngx_http_userid_reset_index); |
544 | |
7028
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
545 if (vv == NULL || vv->not_found) { |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
546 return NGX_ERROR; |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
547 } |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
548 |
3943 | 549 if (vv->len == 0 || (vv->len == 1 && vv->data[0] == '0')) { |
550 | |
551 if (conf->mark == '\0' | |
552 || (ctx->cookie.len > 23 | |
553 && ctx->cookie.data[22] == conf->mark | |
554 && ctx->cookie.data[23] == '=')) | |
555 { | |
556 return NGX_OK; | |
557 } | |
558 | |
559 ctx->uid_set[0] = ctx->uid_got[0]; | |
560 ctx->uid_set[1] = ctx->uid_got[1]; | |
561 ctx->uid_set[2] = ctx->uid_got[2]; | |
562 ctx->uid_set[3] = ctx->uid_got[3]; | |
563 | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
564 return NGX_OK; |
3943 | 565 |
566 } else { | |
567 ctx->reset = 1; | |
568 | |
569 if (vv->len == 3 && ngx_strncmp(vv->data, "log", 3) == 0) { | |
570 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, | |
571 "userid cookie \"%V=%08XD%08XD%08XD%08XD\" was reset", | |
572 &conf->name, ctx->uid_got[0], ctx->uid_got[1], | |
573 ctx->uid_got[2], ctx->uid_got[3]); | |
574 } | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
575 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
576 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
577 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
578 /* |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
579 * TODO: in the threaded mode the sequencers should be in TLS and their |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
580 * ranges should be divided between threads |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
581 */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
582 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
583 if (conf->enable == NGX_HTTP_USERID_V1) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
584 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
585 ctx->uid_set[0] = 0; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
586 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
587 ctx->uid_set[0] = conf->service; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
588 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
589 ctx->uid_set[1] = (uint32_t) ngx_time(); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
590 ctx->uid_set[2] = start_value; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
591 ctx->uid_set[3] = sequencer_v1; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
592 sequencer_v1 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
593 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
594 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
595 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
596 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
597 c = r->connection; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
598 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
599 if (ngx_connection_local_sockaddr(c, NULL, 0) != NGX_OK) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
600 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
601 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
602 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
603 switch (c->local_sockaddr->sa_family) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
604 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
605 #if (NGX_HAVE_INET6) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
606 case AF_INET6: |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
607 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
608 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
609 p = (u_char *) &ctx->uid_set[0]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
610 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
611 *p++ = sin6->sin6_addr.s6_addr[12]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
612 *p++ = sin6->sin6_addr.s6_addr[13]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
613 *p++ = sin6->sin6_addr.s6_addr[14]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
614 *p = sin6->sin6_addr.s6_addr[15]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
615 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
616 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
617 #endif |
7432
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
618 |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
619 #if (NGX_HAVE_UNIX_DOMAIN) |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
620 case AF_UNIX: |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
621 ctx->uid_set[0] = 0; |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
622 break; |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
623 #endif |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
624 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
625 default: /* AF_INET */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
626 sin = (struct sockaddr_in *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
627 ctx->uid_set[0] = sin->sin_addr.s_addr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
628 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
629 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
630 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
631 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
632 ctx->uid_set[0] = htonl(conf->service); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
633 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
634 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
635 ctx->uid_set[1] = htonl((uint32_t) ngx_time()); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
636 ctx->uid_set[2] = htonl(start_value); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
637 ctx->uid_set[3] = htonl(sequencer_v2); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
638 sequencer_v2 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
639 if (sequencer_v2 < 0x03030302) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
640 sequencer_v2 = 0x03030302; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
641 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
642 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
643 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
644 return NGX_OK; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
645 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
646 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
647 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
648 static ngx_int_t |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
649 ngx_http_userid_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
650 ngx_str_t *name, uint32_t *uid) |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
651 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
652 v->len = name->len + sizeof("=00001111222233334444555566667777") - 1; |
2049 | 653 v->data = ngx_pnalloc(r->pool, v->len); |
573 | 654 if (v->data == NULL) { |
655 return NGX_ERROR; | |
656 } | |
657 | |
657 | 658 v->valid = 1; |
1565 | 659 v->no_cacheable = 0; |
657 | 660 v->not_found = 0; |
661 | |
573 | 662 ngx_sprintf(v->data, "%V=%08XD%08XD%08XD%08XD", |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
663 name, uid[0], uid[1], uid[2], uid[3]); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
664 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
665 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
666 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
667 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
668 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
669 static ngx_int_t |
3943 | 670 ngx_http_userid_reset_variable(ngx_http_request_t *r, |
671 ngx_http_variable_value_t *v, uintptr_t data) | |
672 { | |
673 *v = ngx_http_variable_null_value; | |
674 | |
675 return NGX_OK; | |
676 } | |
677 | |
678 | |
679 static ngx_int_t | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
680 ngx_http_userid_add_variables(ngx_conf_t *cf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
681 { |
3943 | 682 ngx_int_t n; |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
683 ngx_http_variable_t *var; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
684 |
3522
d24f030507cd
allow to use $uid_got in SSI and perl module
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
685 var = ngx_http_add_variable(cf, &ngx_http_userid_got, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
686 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
687 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
688 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
689 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
690 var->get_handler = ngx_http_userid_got_variable; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
691 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
692 var = ngx_http_add_variable(cf, &ngx_http_userid_set, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
693 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
694 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
695 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
696 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
697 var->get_handler = ngx_http_userid_set_variable; |
573 | 698 |
3943 | 699 var = ngx_http_add_variable(cf, &ngx_http_userid_reset, |
700 NGX_HTTP_VAR_CHANGEABLE); | |
701 if (var == NULL) { | |
702 return NGX_ERROR; | |
703 } | |
704 | |
705 var->get_handler = ngx_http_userid_reset_variable; | |
706 | |
707 n = ngx_http_get_variable_index(cf, &ngx_http_userid_reset); | |
708 if (n == NGX_ERROR) { | |
709 return NGX_ERROR; | |
710 } | |
711 | |
712 ngx_http_userid_reset_index = n; | |
713 | |
573 | 714 return NGX_OK; |
715 } | |
716 | |
717 | |
499 | 718 static void * |
719 ngx_http_userid_create_conf(ngx_conf_t *cf) | |
577 | 720 { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
721 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
722 |
499 | 723 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)); |
724 if (conf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
725 return NULL; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
726 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
727 |
479 | 728 /* |
729 * set by ngx_pcalloc(): | |
730 * | |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
731 * conf->flags = 0; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
732 * conf->name = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
733 * conf->domain = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
734 * conf->path = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
735 * conf->p3p = { 0, NULL }; |
479 | 736 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
737 |
509 | 738 conf->enable = NGX_CONF_UNSET_UINT; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
739 conf->service = NGX_CONF_UNSET; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
740 conf->expires = NGX_CONF_UNSET; |
539 | 741 conf->mark = (u_char) '\xFF'; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
742 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
743 return conf; |
577 | 744 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
745 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
746 |
499 | 747 static char * |
748 ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
750 ngx_http_userid_conf_t *prev = parent; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
751 ngx_http_userid_conf_t *conf = child; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
752 |
663 | 753 ngx_conf_merge_uint_value(conf->enable, prev->enable, |
754 NGX_HTTP_USERID_OFF); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
755 |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
756 ngx_conf_merge_bitmask_value(conf->flags, prev->flags, |
8122
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8120
diff
changeset
|
757 (NGX_CONF_BITMASK_SET|NGX_HTTP_USERID_COOKIE_OFF)); |
8120
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
758 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
759 ngx_conf_merge_str_value(conf->name, prev->name, "uid"); |
479 | 760 ngx_conf_merge_str_value(conf->domain, prev->domain, ""); |
461 | 761 ngx_conf_merge_str_value(conf->path, prev->path, "; path=/"); |
479 | 762 ngx_conf_merge_str_value(conf->p3p, prev->p3p, ""); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
763 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
764 ngx_conf_merge_value(conf->service, prev->service, NGX_CONF_UNSET); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
765 ngx_conf_merge_sec_value(conf->expires, prev->expires, 0); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
766 |
539 | 767 if (conf->mark == (u_char) '\xFF') { |
768 if (prev->mark == (u_char) '\xFF') { | |
769 conf->mark = '\0'; | |
770 } else { | |
771 conf->mark = prev->mark; | |
772 } | |
773 } | |
774 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 return NGX_CONF_OK; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
776 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
777 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
778 |
681 | 779 static ngx_int_t |
780 ngx_http_userid_init(ngx_conf_t *cf) | |
781 { | |
782 ngx_http_next_header_filter = ngx_http_top_header_filter; | |
783 ngx_http_top_header_filter = ngx_http_userid_filter; | |
784 | |
785 return NGX_OK; | |
786 } | |
787 | |
788 | |
499 | 789 static char * |
790 ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data) | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
791 { |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
792 ngx_str_t *domain = data; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
793 |
461 | 794 u_char *p, *new; |
795 | |
503 | 796 if (ngx_strcmp(domain->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
797 ngx_str_set(domain, ""); |
461 | 798 return NGX_CONF_OK; |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
799 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
800 |
2049 | 801 new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len); |
499 | 802 if (new == NULL) { |
461 | 803 return NGX_CONF_ERROR; |
804 } | |
805 | |
806 p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1); | |
501 | 807 ngx_memcpy(p, domain->data, domain->len); |
461 | 808 |
809 domain->len += sizeof("; domain=") - 1; | |
810 domain->data = new; | |
811 | |
812 return NGX_CONF_OK; | |
813 } | |
814 | |
815 | |
499 | 816 static char * |
817 ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data) | |
461 | 818 { |
819 ngx_str_t *path = data; | |
820 | |
821 u_char *p, *new; | |
822 | |
2049 | 823 new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len); |
499 | 824 if (new == NULL) { |
461 | 825 return NGX_CONF_ERROR; |
826 } | |
827 | |
828 p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1); | |
501 | 829 ngx_memcpy(p, path->data, path->len); |
461 | 830 |
831 path->len += sizeof("; path=") - 1; | |
832 path->data = new; | |
833 | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
834 return NGX_CONF_OK; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
835 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
836 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
837 |
499 | 838 static char * |
839 ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
840 { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
841 ngx_http_userid_conf_t *ucf = conf; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
842 |
539 | 843 ngx_str_t *value; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
844 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
845 if (ucf->expires != NGX_CONF_UNSET) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
846 return "is duplicate"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
847 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
848 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
849 value = cf->args->elts; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
850 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
851 if (ngx_strcmp(value[1].data, "max") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
852 ucf->expires = NGX_HTTP_USERID_MAX_EXPIRES; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
853 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
854 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
855 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
856 if (ngx_strcmp(value[1].data, "off") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
857 ucf->expires = 0; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
858 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
859 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
860 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
861 ucf->expires = ngx_parse_time(&value[1], 1); |
4474 | 862 if (ucf->expires == (time_t) NGX_ERROR) { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
863 return "invalid value"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
864 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
865 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
866 return NGX_CONF_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
867 } |
461 | 868 |
869 | |
499 | 870 static char * |
871 ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data) | |
461 | 872 { |
873 ngx_str_t *p3p = data; | |
874 | |
503 | 875 if (ngx_strcmp(p3p->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
876 ngx_str_set(p3p, ""); |
461 | 877 } |
878 | |
879 return NGX_CONF_OK; | |
880 } | |
539 | 881 |
882 | |
883 static char * | |
884 ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
885 { | |
886 ngx_http_userid_conf_t *ucf = conf; | |
887 | |
888 ngx_str_t *value; | |
889 | |
890 if (ucf->mark != (u_char) '\xFF') { | |
891 return "is duplicate"; | |
892 } | |
893 | |
894 value = cf->args->elts; | |
895 | |
896 if (ngx_strcmp(value[1].data, "off") == 0) { | |
897 ucf->mark = '\0'; | |
898 return NGX_CONF_OK; | |
899 } | |
900 | |
901 if (value[1].len != 1 | |
902 || !((value[1].data[0] >= '0' && value[1].data[0] <= '9') | |
903 || (value[1].data[0] >= 'A' && value[1].data[0] <= 'Z') | |
904 || (value[1].data[0] >= 'a' && value[1].data[0] <= 'z') | |
905 || value[1].data[0] == '=')) | |
906 { | |
907 return "value must be \"off\" or a single letter, digit or \"=\""; | |
908 } | |
909 | |
910 ucf->mark = value[1].data[0]; | |
911 | |
912 return NGX_CONF_OK; | |
913 } | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
914 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
915 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
916 static ngx_int_t |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
917 ngx_http_userid_init_worker(ngx_cycle_t *cycle) |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
918 { |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
919 struct timeval tp; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
920 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
921 ngx_gettimeofday(&tp); |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
922 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
923 /* use the most significant usec part that fits to 16 bits */ |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
4499
diff
changeset
|
924 start_value = (((uint32_t) tp.tv_usec / 20) << 16) | ngx_pid; |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
925 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
926 return NGX_OK; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
927 } |