mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-14 16:09:32 +01:00
sasl: Follow PLAIN spec more closely
This commit is contained in:
parent
cc910d0e6e
commit
1cc217a9ae
@ -171,16 +171,20 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
|
|||||||
func authPlainHandler(server *Server, client *Client, mechanism string, value []byte) bool {
|
func authPlainHandler(server *Server, client *Client, mechanism string, value []byte) bool {
|
||||||
splitValue := bytes.Split(value, []byte{'\000'})
|
splitValue := bytes.Split(value, []byte{'\000'})
|
||||||
|
|
||||||
if len(splitValue) != 3 {
|
var accountKey, authzid string
|
||||||
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob")
|
|
||||||
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
accountKey := string(splitValue[0])
|
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob")
|
||||||
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user