From b5a868bbcd408c0c3f3c22e4bc0a128df34babc9 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 19 Nov 2021 18:55:07 +0100 Subject: [PATCH] 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. --- downstream.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/downstream.go b/downstream.go index f60dbc9..3524493 100644 --- a/downstream.go +++ b/downstream.go @@ -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 {