forked from jshiffer/go-xmpp
Fix manual choice of auth mechanism. (#173)
This commit is contained in:
parent
5fdcf18a81
commit
424970d23c
65
xmpp.go
65
xmpp.go
@ -406,37 +406,40 @@ func (c *Client) init(o *Options) error {
|
|||||||
tlsConnOK = true
|
tlsConnOK = true
|
||||||
}
|
}
|
||||||
mechanism = ""
|
mechanism = ""
|
||||||
switch {
|
if o.Mechanism != "" {
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
if slices.Contains(f.Mechanisms.Mechanism, o.Mechanism) {
|
||||||
o.Mechanism) && o.Mechanism != "":
|
mechanism = o.Mechanism
|
||||||
mechanism = o.Mechanism
|
}
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
} else {
|
||||||
"SCRAM-SHA-512-PLUS") && tlsConnOK:
|
switch {
|
||||||
mechanism = "SCRAM-SHA-512-PLUS"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-512-PLUS") && tlsConnOK:
|
||||||
"SCRAM-SHA-256-PLUS") && tlsConnOK:
|
mechanism = "SCRAM-SHA-512-PLUS"
|
||||||
mechanism = "SCRAM-SHA-256-PLUS"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-256-PLUS") && tlsConnOK:
|
||||||
"SCRAM-SHA-1-PLUS") && tlsConnOK:
|
mechanism = "SCRAM-SHA-256-PLUS"
|
||||||
mechanism = "SCRAM-SHA-1-PLUS"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-1-PLUS") && tlsConnOK:
|
||||||
"SCRAM-SHA-512"):
|
mechanism = "SCRAM-SHA-1-PLUS"
|
||||||
mechanism = "SCRAM-SHA-512"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-512"):
|
||||||
"SCRAM-SHA-256"):
|
mechanism = "SCRAM-SHA-512"
|
||||||
mechanism = "SCRAM-SHA-256"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-256"):
|
||||||
"SCRAM-SHA-1"):
|
mechanism = "SCRAM-SHA-256"
|
||||||
mechanism = "SCRAM-SHA-1"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"SCRAM-SHA-1"):
|
||||||
"X-OAUTH2"):
|
mechanism = "SCRAM-SHA-1"
|
||||||
mechanism = "X-OAUTH2"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"X-OAUTH2"):
|
||||||
"PLAIN") && tlsConnOK:
|
mechanism = "X-OAUTH2"
|
||||||
mechanism = "PLAIN"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
case slices.Contains(f.Mechanisms.Mechanism,
|
"PLAIN") && tlsConnOK:
|
||||||
"DIGEST-MD5"):
|
mechanism = "PLAIN"
|
||||||
mechanism = "DIGEST-MD5"
|
case slices.Contains(f.Mechanisms.Mechanism,
|
||||||
|
"DIGEST-MD5"):
|
||||||
|
mechanism = "DIGEST-MD5"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(mechanism, "SCRAM-SHA") {
|
if strings.HasPrefix(mechanism, "SCRAM-SHA") {
|
||||||
if strings.HasSuffix(mechanism, "PLUS") {
|
if strings.HasSuffix(mechanism, "PLUS") {
|
||||||
|
Loading…
Reference in New Issue
Block a user