Giter Site home page Giter Site logo

AUTH LOGIN support about aiosmtpd HOT 2 CLOSED

mdehus avatar mdehus commented on August 28, 2024 2
AUTH LOGIN support

from aiosmtpd.

Comments (2)

Mortal avatar Mortal commented on August 28, 2024

Be sure to have a look at PR #66 to see the ongoing effort on implementing AUTH.

To solve the issue of reading additional information on a new line, use yield from self._reader.readline() in your smtp_AUTH() method. You might do something like:

class AuthSMTP(aiosmtpd.smtp.SMTP):
    @asyncio.coroutine
    def smtp_AUTH(self, arg):
        if arg != 'PLAIN':
            yield from self.push('501 Syntax: AUTH PLAIN')
            return
        yield from self.push('334')
        try:
            second_line = yield from self._reader.readline()
        except (ConnectionResetError, asyncio.CancelledError) as error:
            # How to recover here?
            TODO
        try:
            second_line = second_line.rstrip(b'\r\n').decode('ascii')
        except UnicodeDecodeError:
            yield from self.push('500 Error: Challenge must be ASCII')
            return
        if second_line == 'dGVzdAB0ZXN0ADEyMzQ=':
            self.authenticated = True
            yield from self.push('235 Authentication successful')
        else:
            yield from self.push('535 Invalid credentials')

Of course, a bigger issue with implementing AUTH is changing the SMTP class to require authentication before issuing any other command, but that doesn't appear to be what you're asking about.

from aiosmtpd.

pepoluan avatar pepoluan commented on August 28, 2024

This has been fully implemented in PR #192 , waiting to be Code Reviewed & Merged.

from aiosmtpd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.