3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-14 07:59:31 +01:00

sasl: Follow PLAIN spec more closely

This commit is contained in:
Daniel Oaks 2016-12-01 18:48:11 +10:00
parent cc910d0e6e
commit 1cc217a9ae

View File

@ -171,16 +171,20 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
func authPlainHandler(server *Server, client *Client, mechanism string, value []byte) bool {
splitValue := bytes.Split(value, []byte{'\000'})
if len(splitValue) != 3 {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob")
var accountKey, authzid string
if len(splitValue) == 3 {
accountKey = string(splitValue[0])
authzid = string(splitValue[1])
if accountKey == "" {
accountKey = authzid
} else if accountKey != authzid {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: authcid and authzid should be the same")
return false
}
accountKey := string(splitValue[0])
authzid := string(splitValue[1])
if accountKey != authzid {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: authcid and authzid should be the same")
} else {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob")
return false
}