diff --git a/index.html b/index.html index e30e596..e031aa1 100644 --- a/index.html +++ b/index.html @@ -100,33 +100,42 @@
- +
+
+
- - +
+
+ + +
+
+ + +
+
- Error: wrong password + Error: wrong password or token
-
-
-
- +
@@ -151,6 +166,7 @@
+

Use TLS encryption

WeeChat version 0.4.2 or higher is required—we recommend at least 1.0.

To start using Glowing Bear, follow the instructions below to set up an encrypted relay. All communication goes directly between your browser and your WeeChat relay! This means that your server must be accessible. We never see any of your data or your password, and you don't need to trust a "cloud". All settings, including your password, are saved locally in your own browser between sessions.

You're using Glowing Bear over an unencrypted connection (http://). This is not recommended! We recommend using our secure hosted version at https://www.glowing-bear.org/, or https://latest.glowing-bear.org for the latest and greatest development version. You can still follow the instructions below to set up an encrypted relay, though.
@@ -168,6 +184,11 @@ chown -R username:username ~username

Your certificate needs to be renewed every couple of months. Either follow the instructions for automatic renewal at https://certbot.eff.org, or run certbot renew manually when renewal is due. Important: You'll need to follow the instructions for copying the certificate to the right place again, and re-run /relay sslcertkey in WeeChat.

+

Use TOTP (Time-based One-Time Password)

+

Configure WeeChat for TOTP. The secret key has to be a base 32 string.

+
/secure set relay_totp_secret xxxxx
+/set relay.network.totp_secret "${sec.data.relay_totp_secret}"
+

Open an authenticator app and create an entry with the same secret. In Glowing Bear check the checkbox for "use Time-based One-Time Password" and fill in the one time password as you see it in the authenticator app.

diff --git a/js/connection.js b/js/connection.js index 1347551..b521332 100644 --- a/js/connection.js +++ b/js/connection.js @@ -20,7 +20,7 @@ weechat.factory('connection', var locked = false; // Takes care of the connection and websocket hooks - var connect = function (host, port, path, passwd, ssl, noCompression, successCallback, failCallback) { + var connect = function (host, port, path, passwd, ssl, useTotp, totp, noCompression, successCallback, failCallback) { $rootScope.passwordError = false; connectionData = [host, port, path, passwd, ssl, noCompression]; var proto = ssl ? 'wss' : 'ws'; @@ -45,7 +45,9 @@ weechat.factory('connection', ngWebsockets.send( weeChat.Protocol.formatInit({ password: passwd, - compression: noCompression ? 'off' : 'zlib' + compression: noCompression ? 'off' : 'zlib', + useTotp: useTotp, + totp: totp }) ); @@ -326,9 +328,16 @@ weechat.factory('connection', }; var attemptReconnect = function (bufferId, timeout) { + // won't work if totp is mandatory + if (settings.useTotp) + { + $log.info('Not reconnecting because totp will be expired.'); + return; + } + $log.info('Attempting to reconnect...'); var d = connectionData; - connect(d[0], d[1], d[2], d[3], d[4], function() { + connect(d[0], d[1], d[2], d[3], d[4], false, "", function() { $rootScope.reconnecting = false; // on success, update active buffer models.setActiveBuffer(bufferId); diff --git a/js/glowingbear.js b/js/glowingbear.js index 1dd2291..5111d52 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -45,6 +45,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'port': 9001, 'path': 'weechat', 'ssl': (window.location.protocol === "https:"), + 'useTotp': false, 'savepassword': false, 'autoconnect': false, 'nonicklist': utils.isMobileUi(), @@ -687,6 +688,16 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }; + settings.addCallback('useTotp', function() { + if (settings.useTotp) { + settings.autoconnect = false; + } + }); + + $scope.parseTotp = function() { + $scope.totpInvalid = !/^\d{4,10}$/.test($scope.totp); + }; + $scope.connect = function() { notifications.requestNotificationPermission(); $rootScope.sslError = false; @@ -695,7 +706,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; - connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); + connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl, settings.useTotp, $scope.totp); + $scope.totp = "";//clear for next time }; $scope.disconnect = function() { diff --git a/js/weechat.js b/js/weechat.js index 4d06ff5..f46e3ef 100644 --- a/js/weechat.js +++ b/js/weechat.js @@ -648,6 +648,9 @@ if (params.password !== null) { keys.push('password=' + params.password); } + if (params.useTotp) { + keys.push('totp=' + params.totp); + } parts.push(keys.join(',')); return WeeChatProtocol._formatCmd(null, 'init', parts);