comparison ngx_http_auth_request_module.c @ 1:dfc5ae42367a

Auth request: support switching off.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 26 Feb 2010 21:21:22 +0300
parents 436da5355bd5
children 35f0ee7a3c28
comparison
equal deleted inserted replaced
0:436da5355bd5 1:dfc5ae42367a
25 void *data, ngx_int_t rc); 25 void *data, ngx_int_t rc);
26 static void *ngx_http_auth_request_create_conf(ngx_conf_t *cf); 26 static void *ngx_http_auth_request_create_conf(ngx_conf_t *cf);
27 static char *ngx_http_auth_request_merge_conf(ngx_conf_t *cf, 27 static char *ngx_http_auth_request_merge_conf(ngx_conf_t *cf,
28 void *parent, void *child); 28 void *parent, void *child);
29 static ngx_int_t ngx_http_auth_request_init(ngx_conf_t *cf); 29 static ngx_int_t ngx_http_auth_request_init(ngx_conf_t *cf);
30 static char *ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd,
31 void *conf);
30 32
31 33
32 static ngx_command_t ngx_http_auth_request_commands[] = { 34 static ngx_command_t ngx_http_auth_request_commands[] = {
33 35
34 { ngx_string("auth_request"), 36 { ngx_string("auth_request"),
35 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 37 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
36 ngx_conf_set_str_slot, 38 ngx_http_auth_request,
37 NGX_HTTP_LOC_CONF_OFFSET, 39 NGX_HTTP_LOC_CONF_OFFSET,
38 offsetof(ngx_http_auth_request_conf_t, uri), 40 0,
39 NULL }, 41 NULL },
40 42
41 ngx_null_command 43 ngx_null_command
42 }; 44 };
43 45
229 231
230 *h = ngx_http_auth_request_handler; 232 *h = ngx_http_auth_request_handler;
231 233
232 return NGX_OK; 234 return NGX_OK;
233 } 235 }
236
237
238 static char *
239 ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
240 {
241 ngx_http_auth_request_conf_t *arcf = conf;
242
243 ngx_str_t *value;
244
245 if (arcf->uri.data != NULL) {
246 return "is duplicate";
247 }
248
249 value = cf->args->elts;
250
251 if (ngx_strcmp(value[1].data, "off") == 0) {
252 arcf->uri.len = 0;
253 arcf->uri.data = (u_char *) "";
254
255 return NGX_CONF_OK;
256 }
257
258 arcf->uri = value[1];
259
260 return NGX_CONF_OK;
261 }