mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 10:10:08 -08:00
sasl: Follow PLAIN spec more closely
This commit is contained in:
parent
cc910d0e6e
commit
1cc217a9ae
1 changed files with 13 additions and 9 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue