users: added more secure way for fetching authentication tokens.
- we don't expose ALL on single page - request needs a validation before viewing of each token - will later add 2nd layer of auth.
This commit is contained in:
parent
fa30900469
commit
4ac845a76d
11 changed files with 148 additions and 14 deletions
|
|
@ -352,7 +352,7 @@ table.dataTable {
|
|||
margin-bottom: @padding;
|
||||
|
||||
table.rctable td:first-child {
|
||||
width: 340px;
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('user_disable_force_password_reset', '/_admin/users/%(user_id)s/password_reset_disable', ['user_id']);
|
||||
pyroutes.register('user_create_personal_repo_group', '/_admin/users/%(user_id)s/create_repo_group', ['user_id']);
|
||||
pyroutes.register('user_notice_dismiss', '/_admin/users/%(user_id)s/notice_dismiss', ['user_id']);
|
||||
pyroutes.register('edit_user_auth_tokens_view', '/_admin/users/%(user_id)s/edit/auth_tokens/view', ['user_id']);
|
||||
pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']);
|
||||
pyroutes.register('edit_user_ssh_keys', '/_admin/users/%(user_id)s/edit/ssh_keys', ['user_id']);
|
||||
pyroutes.register('edit_user_ssh_keys_generate_keypair', '/_admin/users/%(user_id)s/edit/ssh_keys/generate', ['user_id']);
|
||||
|
|
@ -312,6 +313,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('my_account_update', '/_admin/my_account/update', []);
|
||||
pyroutes.register('my_account_password', '/_admin/my_account/password', []);
|
||||
pyroutes.register('my_account_password_update', '/_admin/my_account/password/update', []);
|
||||
pyroutes.register('my_account_auth_tokens_view', '/_admin/my_account/auth_tokens/view', []);
|
||||
pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []);
|
||||
pyroutes.register('my_account_ssh_keys', '/_admin/my_account/ssh_keys', []);
|
||||
pyroutes.register('my_account_ssh_keys_generate', '/_admin/my_account/ssh_keys/generate', []);
|
||||
|
|
|
|||
|
|
@ -47,3 +47,72 @@ var UsersAutoComplete = function(input_id, user_id) {
|
|||
lookupFilter: autocompleteFilterResult
|
||||
});
|
||||
};
|
||||
|
||||
var _showAuthToken = function (authTokenId, showUrl) {
|
||||
|
||||
Swal.fire({
|
||||
title: _gettext('Show this authentication token?'),
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#84a5d2',
|
||||
cancelButtonColor: '#e85e4d',
|
||||
showClass: {
|
||||
popup: 'swal2-noanimation',
|
||||
backdrop: 'swal2-noanimation'
|
||||
},
|
||||
hideClass: {
|
||||
popup: '',
|
||||
backdrop: ''
|
||||
},
|
||||
confirmButtonText: _gettext('Show'),
|
||||
showLoaderOnConfirm: true,
|
||||
allowOutsideClick: function () {
|
||||
!Swal.isLoading()
|
||||
},
|
||||
preConfirm: function () {
|
||||
|
||||
var postData = {
|
||||
'auth_token_id': authTokenId,
|
||||
'csrf_token': CSRF_TOKEN
|
||||
};
|
||||
return new Promise(function (resolve, reject) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: postData,
|
||||
url: showUrl,
|
||||
headers: {'X-PARTIAL-XHR': true}
|
||||
})
|
||||
.done(function (data) {
|
||||
resolve(data);
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
//reject("Failed to fetch Authentication Token")
|
||||
var message = formatErrorMessage(jqXHR, textStatus, errorThrown)
|
||||
Swal.showValidationMessage('Request failed: {0}'.format(message)
|
||||
)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
.then(function (result) {
|
||||
if (result.value) {
|
||||
var tmpl = ('<code>{0}</code>' +
|
||||
'<i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="{1}" title="Copy Token"></i>');
|
||||
|
||||
Swal.fire({
|
||||
title: _gettext('Authentication Token'),
|
||||
html: tmpl.format(result.value.auth_token, result.value.auth_token),
|
||||
confirmButtonColor: '#84a5d2',
|
||||
cancelButtonColor: '#e85e4d',
|
||||
showClass: {
|
||||
popup: 'swal2-noanimation',
|
||||
backdrop: 'swal2-noanimation'
|
||||
},
|
||||
hideClass: {
|
||||
popup: '',
|
||||
backdrop: ''
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue