diff --git a/aiosmtpd/smtp.py b/aiosmtpd/smtp.py index bf352627..39e70d8b 100644 --- a/aiosmtpd/smtp.py +++ b/aiosmtpd/smtp.py @@ -943,22 +943,28 @@ async def smtp_AUTH(self, arg: str) -> None: return assert self.session is not None if not self.session.extended_smtp: - return await self.push("500 Error: command 'AUTH' not recognized") + await self.push("500 Error: command 'AUTH' not recognized") + return elif self._auth_require_tls and not self._tls_protocol: - return await self.push("538 5.7.11 Encryption required for requested " - "authentication mechanism") + await self.push("538 5.7.11 Encryption required for requested " + "authentication mechanism") + return elif self.session.authenticated: - return await self.push('503 Already authenticated') + await self.push('503 Already authenticated') + return elif not arg: - return await self.push('501 Not enough value') + await self.push('501 Not enough value') + return args = arg.split() if len(args) > 2: - return await self.push('501 Too many values') + await self.push('501 Too many values') + return mechanism = args[0] if mechanism not in self._auth_methods: - return await self.push('504 5.5.4 Unrecognized authentication type') + await self.push('504 5.5.4 Unrecognized authentication type') + return CODE_SUCCESS = "235 2.7.0 Authentication successful" CODE_INVALID = "535 5.7.8 Authentication credentials invalid" diff --git a/examples/authenticated_relayer/make_user_db.py b/examples/authenticated_relayer/make_user_db.py index 0fa3caf3..dbb2d1f7 100644 --- a/examples/authenticated_relayer/make_user_db.py +++ b/examples/authenticated_relayer/make_user_db.py @@ -5,7 +5,6 @@ import sqlite3 from hashlib import pbkdf2_hmac from pathlib import Path -from typing import Dict DB_FILE = "mail.db~"