* http://ircv3.net/specs/extensions/sasl-3.1.html
*/
namespace SaslMech {
-
- /**
- * Check if the given authentication mechanism is likely to be supported.
- *
- * @param[in] saslCapValue QString of SASL capability value, e.g. capValue(IrcCap::SASL)
- * @param[in] saslMechanism Desired SASL mechanism
- * @return True if mechanism supported or unknown, otherwise false
- */
- inline bool maybeSupported(const QString &saslCapValue, const QString &saslMechanism) { return
- ((saslCapValue.length() == 0) || (saslCapValue.contains(saslMechanism, Qt::CaseInsensitive))); }
- // SASL mechanisms are only specified in capability values as part of SASL 3.2. In
- // SASL 3.1, it's handled differently. If we don't know via capability value, assume it's
- // supported to reduce the risk of breaking existing setups.
- // See: http://ircv3.net/specs/extensions/sasl-3.1.html
- // And: http://ircv3.net/specs/extensions/sasl-3.2.html
-
/**
* PLAIN authentication, e.g. hashed password
*/
}
+bool Network::saslMaybeSupports(const QString &saslMechanism) const
+{
+ // Get the SASL capability value
+ QString saslCapValue = capValue(IrcCap::SASL);
+ // SASL mechanisms are only specified in capability values as part of SASL 3.2. In SASL 3.1,
+ // it's handled differently. If we don't know via capability value, assume it's supported to
+ // reduce the risk of breaking existing setups.
+ // See: http://ircv3.net/specs/extensions/sasl-3.1.html
+ // And: http://ircv3.net/specs/extensions/sasl-3.2.html
+ return (saslCapValue.length() == 0)
+ || (saslCapValue.contains(saslMechanism, Qt::CaseInsensitive));
+}
+
+
IrcUser *Network::newIrcUser(const QString &hostmask, const QVariantMap &initData)
{
QString nick(nickFromMask(hostmask).toLower());
#include "ircuser.h"
#include "ircchannel.h"
+// IRCv3 capabilities
+#include "irccap.h"
+
// defined below!
struct NetworkInfo;
// QHash returns the default constructed value if not found, in this case, empty string
// See: https://doc.qt.io/qt-4.8/qhash.html#value
+ /**
+ * Check if the given authentication mechanism is likely to be supported.
+ *
+ * This depends on the server advertising SASL support and either declaring available mechanisms
+ * (SASL 3.2), or just indicating something is supported (SASL 3.1).
+ *
+ * @param[in] saslMechanism Desired SASL mechanism
+ * @return True if mechanism supported or unknown, otherwise false
+ */
+ bool saslMaybeSupports(const QString &saslMechanism) const;
+
IrcUser *newIrcUser(const QString &hostmask, const QVariantMap &initData = QVariantMap());
inline IrcUser *newIrcUser(const QByteArray &hostmask) { return newIrcUser(decodeServerString(hostmask)); }
IrcUser *ircUser(QString nickname) const;
// FIXME use event
#ifdef HAVE_SSL
if (!identityPtr()->sslCert().isNull()) {
- if (IrcCap::SaslMech::maybeSupported(capValue(IrcCap::SASL), IrcCap::SaslMech::EXTERNAL)) {
+ if (saslMaybeSupports(IrcCap::SaslMech::EXTERNAL)) {
// EXTERNAL authentication supported, send request
putRawLine(serverEncode("AUTHENTICATE EXTERNAL"));
} else {
}
} else {
#endif
- if (IrcCap::SaslMech::maybeSupported(capValue(IrcCap::SASL), IrcCap::SaslMech::PLAIN)) {
+ if (saslMaybeSupports(IrcCap::SaslMech::PLAIN)) {
// PLAIN authentication supported, send request
// Only working with PLAIN atm, blowfish later
putRawLine(serverEncode("AUTHENTICATE PLAIN"));