~samwhited/xmpp

3f972ba8e13669a28ea215deb7259585f2370c69 — Sam Whited 5 years ago 74d8369
Don't require separate username in Config
2 files changed, 6 insertions(+), 4 deletions(-)

M config.go
M sasl.go
M config.go => config.go +4 -3
@@ 40,11 40,12 @@ type Config struct {
	// XMPP protocol version
	Version internal.Version

	// The authorization identity, username, and password to authenticate with.
	// The authorization identity, and password to authenticate with.
	// Identity is used when a user wants to act on behalf of another user. For
	// instance, an admin might want to log in as another user to help them
	// troubleshoot an issue. Normally it is left blank.
	Identity, Username, Password string
	// troubleshoot an issue. Normally it is left blank and the localpart of the
	// Origin JID is used.
	Identity, Password string
}

// NewClientConfig constructs a new client-to-server session configuration with

M sasl.go => sasl.go +2 -1
@@ 14,6 14,7 @@ import (

	"mellium.im/sasl"
	"mellium.im/xmpp/internal/saslerr"
	"mellium.im/xmpp/jid"
	"mellium.im/xmpp/ns"
	"mellium.im/xmpp/streamerror"
)


@@ 90,7 91,7 @@ func SASL(mechanisms ...sasl.Mechanism) StreamFeature {
				c := conn.Config()
				opts := []sasl.Option{
					sasl.Authz(c.Identity),
					sasl.Credentials(c.Username, c.Password),
					sasl.Credentials(conn.LocalAddr().(*jid.JID).Localpart(), c.Password),
					sasl.RemoteMechanisms(data.([]string)...),
				}
				if tlsconn, ok := conn.rwc.(*tls.Conn); ok {