Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split server PASS from SASL authentication #689

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ html, body { height:100%; }
#kiwi .server_select { position:relative; width:320px; margin:0 auto; overflow:hidden; }
#kiwi .server_select.initial { margin-top: 3em; }
#kiwi .server_select .more { display: none; }
#kiwi .server_select .more tr.server_pass { display:none; }
#kiwi .server_select button { }
#kiwi .server_select input { }
#kiwi .server_select label { }
Expand Down
10 changes: 10 additions & 0 deletions client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ _kiwi.global = {
if (_kiwi.app.server_settings.client.ssl)
defaults.ssl = _kiwi.app.server_settings.client.ssl;

if (_kiwi.app.server_settings.client.server_pass)
defaults.server_pass = _kiwi.app.server_settings.client.server_pass;

if (_kiwi.app.server_settings.client.channel)
defaults.channel = _kiwi.app.server_settings.client.channel;

Expand All @@ -327,6 +330,9 @@ _kiwi.global = {
if (getQueryVariable('nick'))
defaults.nick = getQueryVariable('nick');

if (getQueryVariable('server_pass'))
defaults.server_pass = getQueryVariable('server_pass');

if (window.location.hash)
defaults.channel = window.location.hash;

Expand Down Expand Up @@ -414,6 +420,10 @@ _kiwi.global = {
defaults.ssl = _kiwi.app.server_settings.connection.ssl;
}

if (_kiwi.app.server_settings.connection.server_pass) {
defaults.server_pass = _kiwi.app.server_settings.connection.server_pass;
}

if (_kiwi.app.server_settings.connection.channel) {
defaults.channel = _kiwi.app.server_settings.connection.channel;
}
Expand Down
11 changes: 11 additions & 0 deletions client/src/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@
<td><label for="server_select_ssl">SSL</label></td>
<td><input type="checkbox" class="ssl" id="server_select_ssl"></td>
</tr>

<tr class="server_have_pass">
<td colspan="2">
<label for="server_select_show_server_pass"><%= server_password %></label> <input type="checkbox" id="server_select_show_server_pass" style="width:auto;" />
</td>
</tr>

<tr class="server_pass">
<td><label for="server_select_pass"><%= password %></label></td>
<td><input type="password" class="server_password" id="server_select_pass"></td>
</tr>
</table>
</div>
</form>
Expand Down
2 changes: 2 additions & 0 deletions client/src/models/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ _kiwi.model.Gateway = Backbone.Model.extend({
address: connection_info.host,
port: connection_info.port,
ssl: connection_info.ssl,
server_pass: connection_info.server_pass,
password: connection_info.password
};
connection = new _kiwi.model.Network(inf);
Expand All @@ -171,6 +172,7 @@ _kiwi.model.Gateway = Backbone.Model.extend({
hostname: connection_info.host,
port: connection_info.port,
ssl: connection_info.ssl,
server_pass:connection_info.server_pass,
password: connection_info.password
};

Expand Down
7 changes: 7 additions & 0 deletions client/src/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

/**
* The password to connect to this network
* @type String
*/
server_pass: '',

/**
* The password to authenticate to this network
* @type String
*/
password: '',
Expand Down Expand Up @@ -90,6 +96,7 @@
host: this.get('address'),
port: this.get('port'),
ssl: this.get('ssl'),
server_pass:this.get('server_pass'),
password: this.get('password')
};

Expand Down
1 change: 1 addition & 0 deletions client/src/models/newconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ _kiwi.model.NewConnection = Backbone.Collection.extend({
host: new_connection_event.server,
port: new_connection_event.port,
ssl: new_connection_event.ssl,
server_pass: new_connection_event.server_pass,
password: new_connection_event.password,
options: new_connection_event.options
}, function(err, network) {
Expand Down
4 changes: 4 additions & 0 deletions client/src/translations/en-gb.po
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ msgstr "Nickname"
msgid "client_views_serverselect_enable_password"
msgstr "I have a password"

#:
msgid "client_views_serverselect_server_password"
msgstr "This server has a password"

#:
msgid "client_views_serverselect_password"
msgstr "Password"
Expand Down
24 changes: 20 additions & 4 deletions client/src/views/serverselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
'submit form': 'submitForm',
'click .show_more': 'showMore',
'change .have_pass input': 'showPass',
'change .server_have_pass input': 'showServerPass',
'change .have_key input': 'showKey',
'click .fa-key': 'channelKeyIconClick',
'click .show_server': 'showServer'
Expand All @@ -22,6 +23,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
start: _kiwi.global.i18n.translate('client_views_serverselect_connection_start').fetch(),
server_network: _kiwi.global.i18n.translate('client_views_serverselect_server_and_network').fetch(),
server: _kiwi.global.i18n.translate('client_views_serverselect_server').fetch(),
server_password: _kiwi.global.i18n.translate('client_views_serverselect_server_password').fetch(),
port: _kiwi.global.i18n.translate('client_views_serverselect_port').fetch(),
powered_by: _kiwi.global.i18n.translate('client_views_serverselect_poweredby').fetch()
};
Expand Down Expand Up @@ -86,6 +88,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
server: $('input.server', this.$el).val(),
port: $('input.port', this.$el).val(),
ssl: $('input.ssl', this.$el).prop('checked'),
server_pass: $('input.server_password', this.$el).val(),
password: $('input.password', this.$el).val(),
channel: $('input.channel', this.$el).val(),
channel_key: $('input.channel_key', this.$el).val(),
Expand All @@ -108,6 +111,14 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
}
},

showServerPass: function (event) {
if (this.$el.find('tr.server_have_pass input').is(':checked')) {
this.$el.find('tr.server_pass').show().find('input').focus();
} else {
this.$el.find('tr.server_pass').hide().find('input').val('');
}
},

channelKeyIconClick: function (event) {
this.$el.find('tr.have_key input').click();
},
Expand Down Expand Up @@ -141,14 +152,15 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
},

populateFields: function (defaults) {
var nick, server, port, channel, channel_key, ssl, password;
var nick, server, port, channel, channel_key, ssl, server_password, password;

defaults = defaults || {};

nick = defaults.nick || '';
server = defaults.server || '';
port = defaults.port || 6667;
ssl = defaults.ssl || 0;
server_pass = defaults.server_pass || '';
password = defaults.password || '';
channel = defaults.channel || '';
channel_key = defaults.channel_key || '';
Expand All @@ -157,13 +169,17 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
$('input.server', this.$el).val(server);
$('input.port', this.$el).val(port);
$('input.ssl', this.$el).prop('checked', ssl);
$('input#server_select_show_pass', this.$el).prop('checked', !(!password));
$('input#server_select_show_server_pass', this.$el).prop('checked', !!server_pass);
$('input#server_select_show_pass', this.$el).prop('checked', !!password);
$('input.password', this.$el).val(password);
if (!(!password)) {
if (!!server_pass) {
$('tr.server_pass', this.$el).show();
}
if (!!password) {
$('tr.pass', this.$el).show();
}
$('input.channel', this.$el).val(channel);
$('input#server_select_show_channel_key', this.$el).prop('checked', !(!channel_key));
$('input#server_select_show_channel_key', this.$el).prop('checked', !!channel_key);
$('input.channel_key', this.$el).val(channel_key);
if (!(!channel_key)) {
$('tr.key', this.$el).show();
Expand Down
3 changes: 2 additions & 1 deletion server/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ Client.prototype.attachKiwiCommands = function() {
if (command.encoding)
options.encoding = command.encoding;

options.password = global.config.restrict_server_password || command.password;
options.server_pass = global.config.restrict_server_password || command.server_pass;
options.password = command.password;

that.state.connect(
(global.config.restrict_server || command.hostname),
Expand Down
5 changes: 3 additions & 2 deletions server/irc/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c
this.user = user; // Contains users real hostname and address
this.username = this.nick.replace(/[^0-9a-zA-Z\-_.\/]/, '');
this.gecos = ''; // Users real-name. Uses default from config if empty
this.server_pass = options.server_pass || '';
this.password = options.password || '';
this.quit_message = ''; // Uses default from config if empty

Expand Down Expand Up @@ -731,8 +732,8 @@ var socketConnectHandler = function () {

that.write('CAP LS');

if (that.password) {
that.write('PASS ' + that.password);
if (that.server_pass) {
that.write('PASS ' + that.server_pass);
}

that.write('NICK ' + that.nick);
Expand Down