From 8d130a9d92a3f11811275a6f20140eb1232c187c Mon Sep 17 00:00:00 2001 From: contact Date: Fri, 19 Nov 2021 17:55:07 +0000 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. git-svn-id: file:///srv/svn/repo/suika/trunk@721 f0ae65fe-ee39-954e-97ec-027ff2717ef4 --- 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 {