alienscience / imapsrv

An IMAP server written in Go
BSD 3-Clause "New" or "Revised" License
48 stars 9 forks source link

Implement the backend for logins #9

Open twitchyliquid64 opened 9 years ago

twitchyliquid64 commented 9 years ago

Presently, logins are mocked up and hard coded for testing purposes:

(command.go, line 51ish)

// TODO: implement login if c.userId == "test" { sess.st = authenticated return ok(c.tag, "LOGIN completed") }

This needs to be replaced with a system that calls upon the mail store to check Authentications:

We need to add:

alienscience commented 9 years ago

It might be good to separate authentication into a separate interface. Alex suggested this in his changes to the README.

EtienneBruines commented 9 years ago

I would love to help on this one. Ideally, we would indeed use a minimalistic interface to do authentication, so anyone could implement it if their favorite backend isn't supported.

Writing tests does seem like a good thing to do, but I would not have any idea about how to test this, other than for the 'dummy' implementation? Thoughts?

One should be able to keep their "authentication" backend separate from their "mail storage" backend. In an extreme (unlikely) scenario, one would use MySQL for the authentication, PostgreSQL for the metadata, and OpenStack Swift for the actual mail storage. All we need is a way to uniquely identify users (e-mail address?) and share that across the different possibly backends.

I'm not yet that familiar with "the git way", when doing anything more than hotfixes. I know I can create another branch, and put a PR up for that. Not sure what you prefer for the discussing about the PR. (at this issue, at that PR, or at the specific commits?)

EtienneBruines commented 9 years ago

Another thing I'm not really sure on how to handle it. Multiple implementations are nice, but where do we store them? Keeping them all in the same package, would turn into a lot of (go) dependencies. But I don't see any conditional package-loading being done in Go, so I'm not really sure ... (I don't know if these dependencies are bad, since the end-result is just one simple binary)

It's a WIP, but I've made a start here: https://github.com/EtienneBruines/imapsrv/commit/c2a8da82c60e55d994a9d70c298d17d465ec1090

alienscience commented 9 years ago

Hello, you're a contributor now so please take any issues you want. My preference is for Auth and Mailstorage to be interfaces and then people can provide their own implementations.

I see you have already added MySQL and BoltDB in a subpackage - I think this is a good solution. There is no need to add a lot of backends unless you really want to.