https://github.com/foxcpp/go-dovecot-sasl
Go library implementing client and server side of Dovecot authentication protocol 1.1
https://github.com/foxcpp/go-dovecot-sasl
Last synced: 12 months ago
JSON representation
Go library implementing client and server side of Dovecot authentication protocol 1.1
- Host: GitHub
- URL: https://github.com/foxcpp/go-dovecot-sasl
- Owner: foxcpp
- License: mit
- Created: 2020-05-04T17:32:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-22T22:37:46.000Z (almost 6 years ago)
- Last Synced: 2025-03-27T02:38:23.465Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-dovecot-sasl
[](https://pkg.go.dev/github.com/foxcpp/go-dovecot-sasl)
Go library implementing Dovecot authentication protocol 1.1.
The library is based on
[emersion/go-sasl](https://github.com/emersion/go-sasl).
* Specification: https://wiki.dovecot.org/Design/AuthProtocol
## Examples
### Client
```go
s, err := net.Dial("unix", "/var/lib/dovecot/sasl.sock")
if err != nil {
// Handle error.
}
cl := dovecotsasl.NewClient(s)
err := cl.Do("SMTP",
sasl.NewPlainClient("", "foxcpp", "1234"),
dovecotsasl.RemoteIP(net.IPv4(1,2,3,4)),
dovecotsasl.Secured,
)
if err != nil {
// Nope!
}
// Authenticated!
```
### Server
```go
l, err := net.Listen("unix", "/var/lib/maddy/sasl.sock")
if err != nil {
// Handle error.
}
var authenticator sasl.PlainAuthenticator = func(_, user, pass string) error {
if user == "foxcpp" && pass == "1234" {
return nil
}
return errors.New("nope!")
}
s := NewServer()
s.AddMechanism("PLAIN", dovecotsasl.Mechanism{},
func(*dovecotsasl.AuthReq) sasl.Server {
return sasl.NewPlainServer(authenticator)
})
go s.Serve(l)
```
## License
MIT.