r2496, r2749 merge:
compatibility with Microsoft's
AUTH LOGIN [base64 encoded user name ]
patch by Maxim Dounin
Igor Sysoev
13 years ago
163 | 163 |
unsigned no_sync_literal:1;
|
164 | 164 |
unsigned starttls:1;
|
165 | 165 |
unsigned esmtp:1;
|
166 | |
unsigned auth_method:2;
|
|
166 |
unsigned auth_method:3;
|
167 | 167 |
unsigned auth_wait:1;
|
168 | 168 |
|
169 | 169 |
ngx_str_t login;
|
|
242 | 242 |
#define NGX_SMTP_STARTTLS 13
|
243 | 243 |
|
244 | 244 |
|
245 | |
#define NGX_MAIL_AUTH_PLAIN 0
|
246 | |
#define NGX_MAIL_AUTH_LOGIN 1
|
247 | |
#define NGX_MAIL_AUTH_APOP 2
|
248 | |
#define NGX_MAIL_AUTH_CRAM_MD5 3
|
|
245 |
#define NGX_MAIL_AUTH_PLAIN 0
|
|
246 |
#define NGX_MAIL_AUTH_LOGIN 1
|
|
247 |
#define NGX_MAIL_AUTH_LOGIN_USERNAME 2
|
|
248 |
#define NGX_MAIL_AUTH_APOP 3
|
|
249 |
#define NGX_MAIL_AUTH_CRAM_MD5 4
|
249 | 250 |
|
250 | 251 |
|
251 | 252 |
#define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002
|
|
328 | 329 |
ngx_int_t ngx_mail_auth_plain(ngx_mail_session_t *s, ngx_connection_t *c,
|
329 | 330 |
ngx_uint_t n);
|
330 | 331 |
ngx_int_t ngx_mail_auth_login_username(ngx_mail_session_t *s,
|
331 | |
ngx_connection_t *c);
|
|
332 |
ngx_connection_t *c, ngx_uint_t n);
|
332 | 333 |
ngx_int_t ngx_mail_auth_login_password(ngx_mail_session_t *s,
|
333 | 334 |
ngx_connection_t *c);
|
334 | 335 |
ngx_int_t ngx_mail_auth_cram_md5_salt(ngx_mail_session_t *s,
|
334 | 334 |
|
335 | 335 |
|
336 | 336 |
ngx_int_t
|
337 | |
ngx_mail_auth_login_username(ngx_mail_session_t *s, ngx_connection_t *c)
|
|
337 |
ngx_mail_auth_login_username(ngx_mail_session_t *s, ngx_connection_t *c,
|
|
338 |
ngx_uint_t n)
|
338 | 339 |
{
|
339 | 340 |
ngx_str_t *arg;
|
340 | 341 |
|
341 | 342 |
arg = s->args.elts;
|
342 | 343 |
|
343 | 344 |
ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
|
344 | |
"mail auth login username: \"%V\"", &arg[0]);
|
345 | |
|
346 | |
s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len));
|
|
345 |
"mail auth login username: \"%V\"", &arg[n]);
|
|
346 |
|
|
347 |
s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[n].len));
|
347 | 348 |
if (s->login.data == NULL){
|
348 | 349 |
return NGX_ERROR;
|
349 | 350 |
}
|
350 | 351 |
|
351 | |
if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) {
|
|
352 |
if (ngx_decode_base64(&s->login, &arg[n]) != NGX_OK) {
|
352 | 353 |
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
353 | 354 |
"client sent invalid base64 encoding in AUTH LOGIN command");
|
354 | 355 |
return NGX_MAIL_PARSE_INVALID_COMMAND;
|
204 | 204 |
break;
|
205 | 205 |
|
206 | 206 |
case ngx_imap_auth_login_username:
|
207 | |
rc = ngx_mail_auth_login_username(s, c);
|
|
207 |
rc = ngx_mail_auth_login_username(s, c, 0);
|
208 | 208 |
|
209 | 209 |
tag = 0;
|
210 | 210 |
s->out.len = sizeof(imap_password) - 1;
|
|
369 | 369 |
|
370 | 370 |
return NGX_OK;
|
371 | 371 |
|
|
372 |
case NGX_MAIL_AUTH_LOGIN_USERNAME:
|
|
373 |
|
|
374 |
s->out.len = sizeof(imap_password) - 1;
|
|
375 |
s->out.data = imap_password;
|
|
376 |
s->mail_state = ngx_imap_auth_login_password;
|
|
377 |
|
|
378 |
return ngx_mail_auth_login_username(s, c, 1);
|
|
379 |
|
372 | 380 |
case NGX_MAIL_AUTH_PLAIN:
|
373 | 381 |
|
374 | 382 |
s->out.len = sizeof(imap_plain_next) - 1;
|
225 | 225 |
break;
|
226 | 226 |
|
227 | 227 |
case ngx_pop3_auth_login_username:
|
228 | |
rc = ngx_mail_auth_login_username(s, c);
|
|
228 |
rc = ngx_mail_auth_login_username(s, c, 0);
|
229 | 229 |
|
230 | 230 |
s->out.len = sizeof(pop3_password) - 1;
|
231 | 231 |
s->out.data = pop3_password;
|
|
473 | 473 |
|
474 | 474 |
return NGX_OK;
|
475 | 475 |
|
|
476 |
case NGX_MAIL_AUTH_LOGIN_USERNAME:
|
|
477 |
|
|
478 |
s->out.len = sizeof(pop3_password) - 1;
|
|
479 |
s->out.data = pop3_password;
|
|
480 |
s->mail_state = ngx_pop3_auth_login_password;
|
|
481 |
|
|
482 |
return ngx_mail_auth_login_username(s, c, 1);
|
|
483 |
|
476 | 484 |
case NGX_MAIL_AUTH_PLAIN:
|
477 | 485 |
|
478 | 486 |
s->out.len = sizeof(pop3_next) - 1;
|
451 | 451 |
break;
|
452 | 452 |
|
453 | 453 |
case ngx_smtp_auth_login_username:
|
454 | |
rc = ngx_mail_auth_login_username(s, c);
|
|
454 |
rc = ngx_mail_auth_login_username(s, c, 0);
|
455 | 455 |
|
456 | 456 |
s->out.len = sizeof(smtp_password) - 1;
|
457 | 457 |
s->out.data = smtp_password;
|
|
595 | 595 |
|
596 | 596 |
return NGX_OK;
|
597 | 597 |
|
|
598 |
case NGX_MAIL_AUTH_LOGIN_USERNAME:
|
|
599 |
|
|
600 |
s->out.len = sizeof(smtp_password) - 1;
|
|
601 |
s->out.data = smtp_password;
|
|
602 |
s->mail_state = ngx_smtp_auth_login_password;
|
|
603 |
|
|
604 |
return ngx_mail_auth_login_username(s, c, 1);
|
|
605 |
|
598 | 606 |
case NGX_MAIL_AUTH_PLAIN:
|
599 | 607 |
|
600 | 608 |
s->out.len = sizeof(smtp_next) - 1;
|