diff --git a/irc/accounts.go b/irc/accounts.go index 36b81e8d..2ec3fd26 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -171,19 +171,23 @@ 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 { + 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 + } + } else { client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob") 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") - return false - } - // keep it the same as in the REG CREATE stage accountKey, err := CasefoldName(accountKey) if err != nil {