Skip to content

Commit 0d0c7fe

Browse files
committed
Support SASL2 FAST authentication
FAST is a cookie-style authentication method that lets clients store and auth with an unguesseable token. It enables clients to forget the user's full password, which is especially important for web-based clients, that are prone to data leaks. Leaked tokens can be invalidated. - https://xmpp.org/extensions/xep-0484.html - https://xmpp.org/extensions/xep-0388.html Intended to fix conversejs/converse.js#3144 Some aside changes I needed for this: - I let handlers listen to the *opening* stanza - Set 'from' on the opening <stream> tag. (ref: https://github.com/xmppjs/xmpp.js/pull/1006/files#r1893267922) - Create a type of handler that can search *nested data*. This made setting up listeners a lot more convenient. - During connection, replace has_features with the direct XML <stream:features> more direct and defensive. - Moved Status.AUTHENTICATING before FAST/SASL Still TODO: - support the other HT- methods from the spec - rewrite the SASL code into sasl.js to look like sasl2.js ? - allow fallback from SASL2 to SASL (currently assumes only ONE login method will be tried per connect(), which could block login if one is failing) - pull SASL2 into sasl2.js and make it a plugin - Disentangle the circular dependency between index.js loading sasl2.js/sasl2_fast.js but them needing to talk to Strophe - Invalidate token on logout (and in the corresponding Converse.js branch, actually forget the token on logout)
1 parent 4b1b33b commit 0d0c7fe

12 files changed

Lines changed: 771 additions & 142 deletions

src/bosh.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class Bosh {
146146

147147
const body = this._buildBody().attrs({
148148
'to': this._conn.domain,
149+
...(this._conn.service.startsWith("https://") ? { 'from': this._conn.jid } : {}),
149150
'xml:lang': 'en',
150151
'wait': this.wait,
151152
'hold': this.hold,
@@ -451,6 +452,7 @@ class Bosh {
451452
if (data[i] === 'restart') {
452453
body.attrs({
453454
'to': this._conn.domain,
455+
...(this._conn.service.startsWith("https://") ? { 'from': this._conn.jid } : {}),
454456
'xml:lang': 'en',
455457
'xmpp:restart': 'true',
456458
'xmlns:xmpp': NS.BOSH,

0 commit comments

Comments
 (0)