numberoverzero / bottom

asyncio-based rfc2812-compliant IRC Client
http://bottom-docs.readthedocs.io
MIT License
74 stars 23 forks source link

Investigate Transparent SASL #54

Open numberoverzero opened 6 years ago

numberoverzero commented 6 years ago

From #53, consider an SASL extension or baking functionality into bottom directly.

numberoverzero commented 6 years ago

Looking through these references:

I think the plain sasl method could look something like this:

import base64

async def sasl_plain(client, authn_id: str, authz_id: str, password: str):
    pieces = authn_id.encode(), authz_id.encode(), password.encode()
    payload = base64.b64encode(bytes(1).join(pieces))
    client.send_raw(payload.decode())
    # TODO wait for first of 900, 903, 904, 905, 906 using the same pattern
    # as the README's example for waiting on MOTD
    # TODO this will require a new handler that processes 900, 903, 904, 905, 906
    # registered with client.raw_handlers.append(some_handler)
larsks commented 3 years ago

If you're taking requests I vote for this one :smile:

numberoverzero commented 3 years ago

Thanks for the comment!

It's been a few years since I added this to the backlog :) I'm happy to take another look though! To help understand what's missing, can you give me a little more information about SASL, and how you want to use it?

From looking over the SASL 3.1 and 3.2 extension notes, as well as RFC4616, there's a handful of commands (9xx) that the client needs to know. It's easy enough to craft a login message (see sample above) but waiting on new commands requires a bit more work. A hacked together solution could copy the unpacking code in bottom.client.rfc2812_handler and drop all the params parsing..