fix(xep): Fix failure with multiple SCRAM negotiators and SASL2
This commit is contained in:
parent
9eb94e5f48
commit
09a849c6eb
@ -1,2 +1,4 @@
|
|||||||
|
set -ex
|
||||||
|
|
||||||
prosodyctl --config ./prosody.cfg.lua register testuser1 localhost abc123
|
prosodyctl --config ./prosody.cfg.lua register testuser1 localhost abc123
|
||||||
prosodyctl --config ./prosody.cfg.lua register testuser2 localhost abc123
|
prosodyctl --config ./prosody.cfg.lua register testuser2 localhost abc123
|
@ -3,14 +3,16 @@ description: A sample command-line application.
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.0 <3.0.0'
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
logging: ^1.0.2
|
logging: ^1.3.0
|
||||||
moxxmpp: 0.3.0
|
moxxmpp:
|
||||||
moxxmpp_socket_tcp: 0.3.0
|
path: ../packages/moxxmpp
|
||||||
|
moxxmpp_socket_tcp:
|
||||||
|
path: ../packages/moxxmpp_socket_tcp
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^2.0.0
|
build_runner: ^2.4.13
|
||||||
test: ^1.16.0
|
test: ^1.25.8
|
||||||
very_good_analysis: ^3.0.1
|
very_good_analysis: ^6.0.0
|
||||||
|
@ -4,6 +4,8 @@ import 'package:moxxmpp_socket_tcp/moxxmpp_socket_tcp.dart';
|
|||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
class TestingTCPSocketWrapper extends TCPSocketWrapper {
|
class TestingTCPSocketWrapper extends TCPSocketWrapper {
|
||||||
|
TestingTCPSocketWrapper() : super(true);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool onBadCertificate(dynamic certificate, String domain) {
|
bool onBadCertificate(dynamic certificate, String domain) {
|
||||||
return true;
|
return true;
|
||||||
@ -27,7 +29,7 @@ void main() {
|
|||||||
ClientToServerNegotiator(),
|
ClientToServerNegotiator(),
|
||||||
TestingTCPSocketWrapper(),
|
TestingTCPSocketWrapper(),
|
||||||
)..connectionSettings = ConnectionSettings(
|
)..connectionSettings = ConnectionSettings(
|
||||||
jid: JID.fromString('testuser@localhost'),
|
jid: JID.fromString('testuser1@localhost'),
|
||||||
password: 'abc123',
|
password: 'abc123',
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: 5222,
|
port: 5222,
|
||||||
@ -40,6 +42,8 @@ void main() {
|
|||||||
]);
|
]);
|
||||||
await conn.registerFeatureNegotiators([
|
await conn.registerFeatureNegotiators([
|
||||||
SaslPlainNegotiator(),
|
SaslPlainNegotiator(),
|
||||||
|
SaslScramNegotiator(9, '', '', ScramHashType.sha1),
|
||||||
|
SaslScramNegotiator(10, '', '', ScramHashType.sha256),
|
||||||
ResourceBindingNegotiator(),
|
ResourceBindingNegotiator(),
|
||||||
FASTSaslNegotiator(),
|
FASTSaslNegotiator(),
|
||||||
Bind2Negotiator(),
|
Bind2Negotiator(),
|
||||||
|
@ -96,7 +96,9 @@ class SaslPlainNegotiator extends Sasl2AuthenticationNegotiator {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
|
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
|
||||||
state = NegotiatorState.done;
|
if (pickedForSasl2) {
|
||||||
|
state = NegotiatorState.done;
|
||||||
|
}
|
||||||
return const Result(true);
|
return const Result(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +363,11 @@ class SaslScramNegotiator extends Sasl2AuthenticationNegotiator {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
|
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
|
||||||
|
// Don't do anything if we have not been picked for SASL2.
|
||||||
|
if (!pickedForSasl2) {
|
||||||
|
return const Result(true);
|
||||||
|
}
|
||||||
|
|
||||||
// When we're done with SASL2, check the additional data to verify the server
|
// When we're done with SASL2, check the additional data to verify the server
|
||||||
// signature.
|
// signature.
|
||||||
state = NegotiatorState.done;
|
state = NegotiatorState.done;
|
||||||
|
Loading…
Reference in New Issue
Block a user