Mercurial > hg > nginx
annotate src/http/modules/ngx_http_userid_filter_module.c @ 9320:cf73b65983c2 default tip
release-1.27.3 tag
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Aug 2024 17:26:33 +0300 |
parents | ef6a3a99a81a |
children |
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 |
7719
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
18 #define NGX_HTTP_USERID_COOKIE_OFF 0x0002 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
19 #define NGX_HTTP_USERID_COOKIE_SECURE 0x0004 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
20 #define NGX_HTTP_USERID_COOKIE_HTTPONLY 0x0008 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
21 #define NGX_HTTP_USERID_COOKIE_SAMESITE 0x0010 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
22 #define NGX_HTTP_USERID_COOKIE_SAMESITE_STRICT 0x0020 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
23 #define NGX_HTTP_USERID_COOKIE_SAMESITE_LAX 0x0040 |
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
24 #define NGX_HTTP_USERID_COOKIE_SAMESITE_NONE 0x0080 |
7717
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; |
7717
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 |
7717
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[] = { |
7719
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
101 { ngx_string("off"), NGX_HTTP_USERID_COOKIE_OFF }, |
7717
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 |
7717
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 { |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
322 ngx_str_t src, dst; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
323 ngx_table_elt_t *cookie; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
324 ngx_http_userid_ctx_t *ctx; |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
325 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
326 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
|
327 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
328 if (ctx) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
329 return ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
330 } |
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 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
333 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
|
334 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
335 return NULL; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
336 } |
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 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
|
339 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
340 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
341 cookie = ngx_http_parse_multi_header_lines(r, r->headers_in.cookie, |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
342 &conf->name, &ctx->cookie); |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
343 if (cookie == NULL) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
344 return ctx; |
509 | 345 } |
461 | 346 |
539 | 347 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
348 "uid cookie: \"%V\"", &ctx->cookie); | |
349 | |
350 if (ctx->cookie.len < 22) { | |
509 | 351 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
352 "client sent too short userid cookie \"%V\"", | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
353 &cookie->value); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
354 return ctx; |
509 | 355 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
356 |
539 | 357 src = ctx->cookie; |
358 | |
509 | 359 /* |
539 | 360 * we have to limit the encoded string to 22 characters because |
361 * 1) cookie may be marked by "userid_mark", | |
362 * 2) and there are already the millions cookies with a garbage | |
363 * instead of the correct base64 trail "==" | |
509 | 364 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
365 |
509 | 366 src.len = 22; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
367 |
509 | 368 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
|
369 |
509 | 370 if (ngx_decode_base64(&dst, &src) == NGX_ERROR) { |
371 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
372 "client sent invalid userid cookie \"%V\"", | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7719
diff
changeset
|
373 &cookie->value); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
374 return ctx; |
509 | 375 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
376 |
509 | 377 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
378 "uid: %08XD%08XD%08XD%08XD", | |
379 ctx->uid_got[0], ctx->uid_got[1], | |
380 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
|
381 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
382 return ctx; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
383 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
384 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
385 |
499 | 386 static ngx_int_t |
387 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | |
388 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
|
389 { |
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
|
390 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
|
391 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
|
392 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
|
393 ngx_table_elt_t *set_cookie, *p3p; |
2528 | 394 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
395 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
|
396 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
397 } |
539 | 398 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
399 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
400 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
|
401 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
402 |
461 | 403 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
|
404 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
405 if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
406 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
|
407 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
408 |
479 | 409 if (conf->domain.len) { |
461 | 410 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
|
411 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
412 |
7717
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
413 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
|
414 len += sizeof("; secure") - 1; |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
415 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
416 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
417 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
|
418 len += sizeof("; httponly") - 1; |
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 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
421 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
|
422 len += sizeof("; samesite=strict") - 1; |
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 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
425 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
|
426 len += sizeof("; samesite=lax") - 1; |
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 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
429 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
|
430 len += sizeof("; samesite=none") - 1; |
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 |
2049 | 433 cookie = ngx_pnalloc(r->pool, len); |
499 | 434 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
|
435 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
|
436 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
437 |
573 | 438 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
|
439 *p++ = '='; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
440 |
3943 | 441 if (ctx->uid_got[3] == 0 || ctx->reset) { |
539 | 442 src.len = 16; |
443 src.data = (u_char *) ctx->uid_set; | |
444 dst.data = p; | |
445 | |
446 ngx_encode_base64(&dst, &src); | |
447 | |
448 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
|
449 |
539 | 450 if (conf->mark) { |
451 *(p - 2) = conf->mark; | |
452 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
453 |
539 | 454 } else { |
455 p = ngx_cpymem(p, ctx->cookie.data, 22); | |
456 *p++ = conf->mark; | |
457 *p++ = '='; | |
458 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
459 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
460 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
|
461 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
|
462 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
463 } 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
|
464 p = ngx_cpymem(p, expires, sizeof("; expires=") - 1); |
455 | 465 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
|
466 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
467 |
573 | 468 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
|
469 |
573 | 470 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
|
471 |
7717
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
472 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
|
473 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
|
474 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
475 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
476 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
|
477 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
|
478 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
479 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
480 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
|
481 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
|
482 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
483 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
484 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
|
485 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
|
486 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
487 |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
488 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
|
489 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
|
490 } |
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
491 |
499 | 492 set_cookie = ngx_list_push(&r->headers_out.headers); |
493 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
|
494 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
|
495 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
496 |
509 | 497 set_cookie->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
498 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
|
499 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
|
500 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
|
501 |
461 | 502 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
503 "uid cookie: \"%V\"", &set_cookie->value); | |
504 | |
479 | 505 if (conf->p3p.len == 0) { |
461 | 506 return NGX_OK; |
507 } | |
508 | |
499 | 509 p3p = ngx_list_push(&r->headers_out.headers); |
510 if (p3p == NULL) { | |
461 | 511 return NGX_ERROR; |
512 } | |
513 | |
509 | 514 p3p->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
515 ngx_str_set(&p3p->key, "P3P"); |
461 | 516 p3p->value = conf->p3p; |
517 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
518 return NGX_OK; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
519 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
520 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
521 |
499 | 522 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
|
523 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
|
524 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
|
525 { |
3943 | 526 ngx_connection_t *c; |
527 struct sockaddr_in *sin; | |
528 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
|
529 #if (NGX_HAVE_INET6) |
3943 | 530 u_char *p; |
531 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
|
532 #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
|
533 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
534 if (ctx->uid_set[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
535 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
536 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
537 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
538 if (ctx->uid_got[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
539 |
3943 | 540 vv = ngx_http_get_indexed_variable(r, ngx_http_userid_reset_index); |
541 | |
7028
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
542 if (vv == NULL || vv->not_found) { |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
543 return NGX_ERROR; |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
544 } |
e6f399a176e7
Userid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6626
diff
changeset
|
545 |
3943 | 546 if (vv->len == 0 || (vv->len == 1 && vv->data[0] == '0')) { |
547 | |
548 if (conf->mark == '\0' | |
549 || (ctx->cookie.len > 23 | |
550 && ctx->cookie.data[22] == conf->mark | |
551 && ctx->cookie.data[23] == '=')) | |
552 { | |
553 return NGX_OK; | |
554 } | |
555 | |
556 ctx->uid_set[0] = ctx->uid_got[0]; | |
557 ctx->uid_set[1] = ctx->uid_got[1]; | |
558 ctx->uid_set[2] = ctx->uid_got[2]; | |
559 ctx->uid_set[3] = ctx->uid_got[3]; | |
560 | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
561 return NGX_OK; |
3943 | 562 |
563 } else { | |
564 ctx->reset = 1; | |
565 | |
566 if (vv->len == 3 && ngx_strncmp(vv->data, "log", 3) == 0) { | |
567 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, | |
568 "userid cookie \"%V=%08XD%08XD%08XD%08XD\" was reset", | |
569 &conf->name, ctx->uid_got[0], ctx->uid_got[1], | |
570 ctx->uid_got[2], ctx->uid_got[3]); | |
571 } | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
572 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
573 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
574 |
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
|
575 /* |
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
|
576 * 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
|
577 * 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
|
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 |
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 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
|
581 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
|
582 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
|
583 } 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
|
584 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
|
585 } |
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 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
|
587 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
|
588 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
|
589 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
|
590 |
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 } 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
|
592 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
|
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 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
|
595 |
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 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
|
597 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
|
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 |
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 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
|
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 #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
|
603 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
|
604 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
|
605 |
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 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
|
607 |
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 *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
|
609 *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
|
610 *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
|
611 *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
|
612 |
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 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
|
614 #endif |
7432
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
615 |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
616 #if (NGX_HAVE_UNIX_DOMAIN) |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
617 case AF_UNIX: |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
618 ctx->uid_set[0] = 0; |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
619 break; |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
620 #endif |
ecc97cb0eda4
Userid: using stub for AF_UNIX addresses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7028
diff
changeset
|
621 |
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
|
622 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
|
623 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
|
624 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
|
625 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
|
626 } |
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 |
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 } 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
|
629 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
|
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 |
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[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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 } |
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 } |
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 |
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 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
|
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 |
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 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
|
646 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
|
647 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
|
648 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
649 v->len = name->len + sizeof("=00001111222233334444555566667777") - 1; |
2049 | 650 v->data = ngx_pnalloc(r->pool, v->len); |
573 | 651 if (v->data == NULL) { |
652 return NGX_ERROR; | |
653 } | |
654 | |
657 | 655 v->valid = 1; |
1565 | 656 v->no_cacheable = 0; |
657 | 657 v->not_found = 0; |
658 | |
573 | 659 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
|
660 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
|
661 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
662 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
663 } |
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 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
666 static ngx_int_t |
3943 | 667 ngx_http_userid_reset_variable(ngx_http_request_t *r, |
668 ngx_http_variable_value_t *v, uintptr_t data) | |
669 { | |
670 *v = ngx_http_variable_null_value; | |
671 | |
672 return NGX_OK; | |
673 } | |
674 | |
675 | |
676 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
|
677 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
|
678 { |
3943 | 679 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
|
680 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
|
681 |
3522
d24f030507cd
allow to use $uid_got in SSI and perl module
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
682 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
|
683 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
684 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
685 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
686 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
687 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
|
688 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
689 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
|
690 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
691 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
692 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
693 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
694 var->get_handler = ngx_http_userid_set_variable; |
573 | 695 |
3943 | 696 var = ngx_http_add_variable(cf, &ngx_http_userid_reset, |
697 NGX_HTTP_VAR_CHANGEABLE); | |
698 if (var == NULL) { | |
699 return NGX_ERROR; | |
700 } | |
701 | |
702 var->get_handler = ngx_http_userid_reset_variable; | |
703 | |
704 n = ngx_http_get_variable_index(cf, &ngx_http_userid_reset); | |
705 if (n == NGX_ERROR) { | |
706 return NGX_ERROR; | |
707 } | |
708 | |
709 ngx_http_userid_reset_index = n; | |
710 | |
573 | 711 return NGX_OK; |
712 } | |
713 | |
714 | |
499 | 715 static void * |
716 ngx_http_userid_create_conf(ngx_conf_t *cf) | |
577 | 717 { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
718 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
|
719 |
499 | 720 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)); |
721 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
|
722 return NULL; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
723 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
724 |
479 | 725 /* |
726 * set by ngx_pcalloc(): | |
727 * | |
7717
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
728 * conf->flags = 0; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
729 * conf->name = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
730 * conf->domain = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
731 * conf->path = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
732 * conf->p3p = { 0, NULL }; |
479 | 733 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
734 |
509 | 735 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
|
736 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
|
737 conf->expires = NGX_CONF_UNSET; |
539 | 738 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
|
739 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
740 return conf; |
577 | 741 } |
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 |
499 | 744 static char * |
745 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
|
746 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
747 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
|
748 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
|
749 |
663 | 750 ngx_conf_merge_uint_value(conf->enable, prev->enable, |
751 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
|
752 |
7717
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
753 ngx_conf_merge_bitmask_value(conf->flags, prev->flags, |
7719
c0cacad62cc8
Userid: userid_flags fixup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7717
diff
changeset
|
754 (NGX_CONF_BITMASK_SET|NGX_HTTP_USERID_COOKIE_OFF)); |
7717
e3e8b8234f05
Userid: userid_flags directive to set cookie flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7432
diff
changeset
|
755 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 ngx_conf_merge_str_value(conf->name, prev->name, "uid"); |
479 | 757 ngx_conf_merge_str_value(conf->domain, prev->domain, ""); |
461 | 758 ngx_conf_merge_str_value(conf->path, prev->path, "; path=/"); |
479 | 759 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
|
760 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
761 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
|
762 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
|
763 |
539 | 764 if (conf->mark == (u_char) '\xFF') { |
765 if (prev->mark == (u_char) '\xFF') { | |
766 conf->mark = '\0'; | |
767 } else { | |
768 conf->mark = prev->mark; | |
769 } | |
770 } | |
771 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
772 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
|
773 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
774 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 |
681 | 776 static ngx_int_t |
777 ngx_http_userid_init(ngx_conf_t *cf) | |
778 { | |
779 ngx_http_next_header_filter = ngx_http_top_header_filter; | |
780 ngx_http_top_header_filter = ngx_http_userid_filter; | |
781 | |
782 return NGX_OK; | |
783 } | |
784 | |
785 | |
499 | 786 static char * |
787 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
|
788 { |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
789 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
|
790 |
461 | 791 u_char *p, *new; |
792 | |
503 | 793 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
|
794 ngx_str_set(domain, ""); |
461 | 795 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
|
796 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
797 |
2049 | 798 new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len); |
499 | 799 if (new == NULL) { |
461 | 800 return NGX_CONF_ERROR; |
801 } | |
802 | |
803 p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1); | |
501 | 804 ngx_memcpy(p, domain->data, domain->len); |
461 | 805 |
806 domain->len += sizeof("; domain=") - 1; | |
807 domain->data = new; | |
808 | |
809 return NGX_CONF_OK; | |
810 } | |
811 | |
812 | |
499 | 813 static char * |
814 ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data) | |
461 | 815 { |
816 ngx_str_t *path = data; | |
817 | |
818 u_char *p, *new; | |
819 | |
2049 | 820 new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len); |
499 | 821 if (new == NULL) { |
461 | 822 return NGX_CONF_ERROR; |
823 } | |
824 | |
825 p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1); | |
501 | 826 ngx_memcpy(p, path->data, path->len); |
461 | 827 |
828 path->len += sizeof("; path=") - 1; | |
829 path->data = new; | |
830 | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
831 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
|
832 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
833 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
834 |
499 | 835 static char * |
836 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
|
837 { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
838 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
|
839 |
539 | 840 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
|
841 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
842 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
|
843 return "is duplicate"; |
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 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
846 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
|
847 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
848 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
|
849 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
|
850 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
|
851 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
852 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
853 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
|
854 ucf->expires = 0; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
855 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
|
856 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
857 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
858 ucf->expires = ngx_parse_time(&value[1], 1); |
4474 | 859 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
|
860 return "invalid value"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
861 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
862 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
863 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
|
864 } |
461 | 865 |
866 | |
499 | 867 static char * |
868 ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data) | |
461 | 869 { |
870 ngx_str_t *p3p = data; | |
871 | |
503 | 872 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
|
873 ngx_str_set(p3p, ""); |
461 | 874 } |
875 | |
876 return NGX_CONF_OK; | |
877 } | |
539 | 878 |
879 | |
880 static char * | |
881 ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
882 { | |
883 ngx_http_userid_conf_t *ucf = conf; | |
884 | |
885 ngx_str_t *value; | |
886 | |
887 if (ucf->mark != (u_char) '\xFF') { | |
888 return "is duplicate"; | |
889 } | |
890 | |
891 value = cf->args->elts; | |
892 | |
893 if (ngx_strcmp(value[1].data, "off") == 0) { | |
894 ucf->mark = '\0'; | |
895 return NGX_CONF_OK; | |
896 } | |
897 | |
898 if (value[1].len != 1 | |
899 || !((value[1].data[0] >= '0' && value[1].data[0] <= '9') | |
900 || (value[1].data[0] >= 'A' && value[1].data[0] <= 'Z') | |
901 || (value[1].data[0] >= 'a' && value[1].data[0] <= 'z') | |
902 || value[1].data[0] == '=')) | |
903 { | |
904 return "value must be \"off\" or a single letter, digit or \"=\""; | |
905 } | |
906 | |
907 ucf->mark = value[1].data[0]; | |
908 | |
909 return NGX_CONF_OK; | |
910 } | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
911 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
912 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
913 static ngx_int_t |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
914 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
|
915 { |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
916 struct timeval tp; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
917 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
918 ngx_gettimeofday(&tp); |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
919 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
920 /* 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
|
921 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
|
922 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
923 return NGX_OK; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
924 } |