Mercurial > hg > nginx
comparison src/http/modules/ngx_http_secure_link_module.c @ 3760:38f74d11e5bd
discard "secure_link_expires on|off"
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 06 Sep 2010 14:19:18 +0000 |
parents | 7224d008faaf |
children | 0a84dc5f5613 |
comparison
equal
deleted
inserted
replaced
3759:c0a91131a12b | 3760:38f74d11e5bd |
---|---|
12 | 12 |
13 typedef struct { | 13 typedef struct { |
14 ngx_http_complex_value_t *variable; | 14 ngx_http_complex_value_t *variable; |
15 ngx_http_complex_value_t *md5; | 15 ngx_http_complex_value_t *md5; |
16 ngx_str_t secret; | 16 ngx_str_t secret; |
17 ngx_flag_t expires; | |
18 } ngx_http_secure_link_conf_t; | 17 } ngx_http_secure_link_conf_t; |
19 | 18 |
20 | 19 |
21 typedef struct { | 20 typedef struct { |
22 ngx_str_t expires; | 21 ngx_str_t expires; |
46 { ngx_string("secure_link_md5"), | 45 { ngx_string("secure_link_md5"), |
47 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 46 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
48 ngx_http_set_comlex_value_slot, | 47 ngx_http_set_comlex_value_slot, |
49 NGX_HTTP_LOC_CONF_OFFSET, | 48 NGX_HTTP_LOC_CONF_OFFSET, |
50 offsetof(ngx_http_secure_link_conf_t, md5), | 49 offsetof(ngx_http_secure_link_conf_t, md5), |
51 NULL }, | |
52 | |
53 { ngx_string("secure_link_expires"), | |
54 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
55 ngx_conf_set_flag_slot, | |
56 NGX_HTTP_LOC_CONF_OFFSET, | |
57 offsetof(ngx_http_secure_link_conf_t, expires), | |
58 NULL }, | 50 NULL }, |
59 | 51 |
60 { ngx_string("secure_link_secret"), | 52 { ngx_string("secure_link_secret"), |
61 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 53 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
62 ngx_conf_set_str_slot, | 54 ngx_conf_set_str_slot, |
139 expires = 0; | 131 expires = 0; |
140 | 132 |
141 if (p) { | 133 if (p) { |
142 val.len = p++ - val.data; | 134 val.len = p++ - val.data; |
143 | 135 |
144 if (conf->expires) { | 136 expires = ngx_atotm(p, last - p); |
145 expires = ngx_atotm(p, last - p); | 137 if (expires <= 0) { |
146 if (expires <= 0) { | 138 goto not_found; |
147 goto not_found; | 139 } |
148 } | 140 |
149 | 141 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_secure_link_ctx_t)); |
150 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_secure_link_ctx_t)); | 142 if (ctx == NULL) { |
151 if (ctx == NULL) { | 143 return NGX_ERROR; |
152 return NGX_ERROR; | 144 } |
153 } | 145 |
154 | 146 ngx_http_set_ctx(r, ctx, ngx_http_secure_link_module); |
155 ngx_http_set_ctx(r, ctx, ngx_http_secure_link_module); | 147 |
156 | 148 ctx->expires.len = last - p; |
157 ctx->expires.len = last - p; | 149 ctx->expires.data = p; |
158 ctx->expires.data = p; | |
159 } | |
160 } | 150 } |
161 | 151 |
162 if (val.len > 24) { | 152 if (val.len > 24) { |
163 goto not_found; | 153 goto not_found; |
164 } | 154 } |
315 * conf->variable = NULL; | 305 * conf->variable = NULL; |
316 * conf->md5 = NULL; | 306 * conf->md5 = NULL; |
317 * conf->secret = { 0, NULL }; | 307 * conf->secret = { 0, NULL }; |
318 */ | 308 */ |
319 | 309 |
320 conf->expires = NGX_CONF_UNSET; | |
321 | |
322 return conf; | 310 return conf; |
323 } | 311 } |
324 | 312 |
325 | 313 |
326 static char * | 314 static char * |
336 } | 324 } |
337 | 325 |
338 if (conf->md5 == NULL) { | 326 if (conf->md5 == NULL) { |
339 conf->md5 = prev->md5; | 327 conf->md5 = prev->md5; |
340 } | 328 } |
341 | |
342 ngx_conf_merge_value(conf->expires, prev->expires, 0); | |
343 | 329 |
344 return NGX_CONF_OK; | 330 return NGX_CONF_OK; |
345 } | 331 } |
346 | 332 |
347 | 333 |