Mercurial > hg > nginx-vendor-0-8
comparison src/imap/ngx_imap_auth_http_module.c @ 252:644510700914 NGINX_0_4_11
nginx 0.4.11
*) Feature: the POP3 proxy supports the AUTH LOGIN PLAIN and CRAM-MD5.
*) Feature: the ngx_http_perl_module supports the $r->allow_ranges
method.
*) Bugfix: if the APOP was enabled in the POP3 proxy, then the
USER/PASS commands might not work; bug appeared in 0.4.10.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 25 Oct 2006 00:00:00 +0400 |
parents | fbf2b2f66c9f |
children | 6ae1357b7b7c |
comparison
equal
deleted
inserted
replaced
251:16ffa8ae5759 | 252:644510700914 |
---|---|
131 }; | 131 }; |
132 | 132 |
133 | 133 |
134 static char *ngx_imap_auth_http_protocol[] = { "pop3", "imap" }; | 134 static char *ngx_imap_auth_http_protocol[] = { "pop3", "imap" }; |
135 static ngx_str_t ngx_imap_auth_http_method[] = { | 135 static ngx_str_t ngx_imap_auth_http_method[] = { |
136 ngx_string("plain"), ngx_string("apop") | 136 ngx_string("plain"), |
137 ngx_string("apop"), | |
138 ngx_string("cram-md5") | |
137 }; | 139 }; |
138 | 140 |
139 | 141 |
140 void | 142 void |
141 ngx_imap_auth_http_init(ngx_imap_session_t *s) | 143 ngx_imap_auth_http_init(ngx_imap_session_t *s) |
1076 | 1078 |
1077 b->last = ngx_cpymem(b->last, "Auth-Pass: ", sizeof("Auth-Pass: ") - 1); | 1079 b->last = ngx_cpymem(b->last, "Auth-Pass: ", sizeof("Auth-Pass: ") - 1); |
1078 b->last = ngx_copy(b->last, passwd.data, passwd.len); | 1080 b->last = ngx_copy(b->last, passwd.data, passwd.len); |
1079 *b->last++ = CR; *b->last++ = LF; | 1081 *b->last++ = CR; *b->last++ = LF; |
1080 | 1082 |
1081 if (s->salt.len) { | 1083 if (s->auth_method != NGX_IMAP_AUTH_PLAIN && s->salt.len) { |
1082 b->last = ngx_cpymem(b->last, "Auth-Salt: ", sizeof("Auth-Salt: ") - 1); | 1084 b->last = ngx_cpymem(b->last, "Auth-Salt: ", sizeof("Auth-Salt: ") - 1); |
1083 b->last = ngx_copy(b->last, s->salt.data, s->salt.len); | 1085 b->last = ngx_copy(b->last, s->salt.data, s->salt.len); |
1084 | 1086 |
1085 s->passwd.data = NULL; | 1087 s->passwd.data = NULL; |
1086 } | 1088 } |
1245 static char * | 1247 static char * |
1246 ngx_imap_auth_http(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1248 ngx_imap_auth_http(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1247 { | 1249 { |
1248 ngx_imap_auth_http_conf_t *ahcf = conf; | 1250 ngx_imap_auth_http_conf_t *ahcf = conf; |
1249 | 1251 |
1250 ngx_str_t *value, *url; | 1252 ngx_str_t *value; |
1251 ngx_inet_upstream_t inet_upstream; | 1253 ngx_url_t u; |
1252 #if (NGX_HAVE_UNIX_DOMAIN) | |
1253 ngx_unix_domain_upstream_t unix_upstream; | |
1254 #endif | |
1255 | 1254 |
1256 value = cf->args->elts; | 1255 value = cf->args->elts; |
1257 | 1256 |
1258 url = &value[1]; | 1257 ngx_memzero(&u, sizeof(ngx_url_t)); |
1259 | 1258 |
1260 if (ngx_strncasecmp(url->data, "unix:", 5) == 0) { | 1259 u.url = value[1]; |
1261 | 1260 u.default_portn = 80; |
1262 #if (NGX_HAVE_UNIX_DOMAIN) | 1261 u.uri_part = 1; |
1263 | 1262 |
1264 ngx_memzero(&unix_upstream, sizeof(ngx_unix_domain_upstream_t)); | 1263 if (ngx_parse_url(cf, &u) != NGX_OK) { |
1265 | 1264 if (u.err) { |
1266 unix_upstream.name = *url; | 1265 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1267 unix_upstream.url = *url; | 1266 "%s in auth_http \"%V\"", u.err, &u.url); |
1268 unix_upstream.uri_part = 1; | 1267 } |
1269 | 1268 } |
1270 ahcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream); | 1269 |
1271 if (ahcf->peers == NULL) { | 1270 ahcf->peers = u.peers; |
1272 return NGX_CONF_ERROR; | 1271 ahcf->peers->number = 1; |
1273 } | 1272 |
1274 | 1273 ahcf->host_header = u.host_header; |
1275 ahcf->host_header.len = sizeof("localhost") - 1; | 1274 ahcf->uri = u.uri; |
1276 ahcf->host_header.data = (u_char *) "localhost"; | |
1277 ahcf->uri = unix_upstream.uri; | |
1278 | |
1279 #else | |
1280 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1281 "the unix domain sockets are not supported " | |
1282 "on this platform"); | |
1283 return NGX_CONF_ERROR; | |
1284 | |
1285 #endif | |
1286 | |
1287 } else { | |
1288 ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t)); | |
1289 | |
1290 inet_upstream.name = *url; | |
1291 inet_upstream.url = *url; | |
1292 inet_upstream.default_port_value = 80; | |
1293 inet_upstream.uri_part = 1; | |
1294 | |
1295 ahcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream); | |
1296 if (ahcf->peers == NULL) { | |
1297 return NGX_CONF_ERROR; | |
1298 } | |
1299 | |
1300 ahcf->peers->number = 1; | |
1301 | |
1302 ahcf->host_header = inet_upstream.host_header; | |
1303 ahcf->uri = inet_upstream.uri; | |
1304 } | |
1305 | 1275 |
1306 if (ahcf->uri.len == 0) { | 1276 if (ahcf->uri.len == 0) { |
1307 ahcf->uri.len = sizeof("/") - 1; | 1277 ahcf->uri.len = sizeof("/") - 1; |
1308 ahcf->uri.data = (u_char *) "/"; | 1278 ahcf->uri.data = (u_char *) "/"; |
1309 } | 1279 } |