Abort SASL if in-progress while completing registration

Implements the following recommendation from the spec:

> If the client completes registration (with CAP END, NICK, USER and any other
> necessary messages) while the SASL authentication is still in progress, the
> server SHOULD abort it and send a 906 numeric, then register the client
> without authentication.
This commit is contained in:
Simon Ser 2021-11-19 18:55:07 +01:00
parent c6f5508765
commit b5a868bbcd

View file

@ -1110,6 +1110,15 @@ func (dc *downstreamConn) register(ctx context.Context) error {
return fmt.Errorf("tried to register twice")
}
if dc.saslServer != nil {
dc.saslServer = nil
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.ERR_SASLABORTED,
Params: []string{"*", "SASL authentication aborted"},
})
}
password := dc.password
dc.password = ""
if dc.user == nil {