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

Several config and admin interface fixes #3436

Merged
merged 1 commit into from
Apr 10, 2023
Merged
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
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
## For details see: https://github.com/dani-garcia/vaultwarden/wiki/Enabling-admin-page#secure-the-admin_token
## If not set, the admin panel is disabled
## New Argon2 PHC string
## Note that for some environments, like docker-compose you need to escape all the dollar signs `$` with an extra dollar sign like `$$`
## Also, use single quotes (') instead of double quotes (") to enclose the string when needed
# ADMIN_TOKEN='$argon2id$v=19$m=65540,t=3,p=4$MmeKRnGK5RW5mJS7h3TOL89GrpLPXJPAtTK8FTqj9HM$DqsstvoSAETl9YhnsXbf43WeaUwJC6JhViIvuPoig78'
## Old plain text string (Will generate warnings in favor of Argon2)
# ADMIN_TOKEN=Vy2VyYTTsKPv8W5aEOWUbB/Bt3DEKePbHmI4m9VcemUMS2rEviDowNAFqYi1xjmp
Expand Down
4 changes: 2 additions & 2 deletions src/api/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ pub fn static_files(filename: String) -> Result<(ContentType, &'static [u8]), Er
"jdenticon.js" => Ok((ContentType::JavaScript, include_bytes!("../static/scripts/jdenticon.js"))),
"datatables.js" => Ok((ContentType::JavaScript, include_bytes!("../static/scripts/datatables.js"))),
"datatables.css" => Ok((ContentType::CSS, include_bytes!("../static/scripts/datatables.css"))),
"jquery-3.6.3.slim.js" => {
Ok((ContentType::JavaScript, include_bytes!("../static/scripts/jquery-3.6.3.slim.js")))
"jquery-3.6.4.slim.js" => {
Ok((ContentType::JavaScript, include_bytes!("../static/scripts/jquery-3.6.4.slim.js")))
}
_ => err!(format!("Static file not found: {filename}")),
}
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ make_config! {
/// provides unauthenticated access to potentially sensitive data.
show_password_hint: bool, true, def, false;

/// Admin page token |> The token used to authenticate in this very same page. Changing it here won't deauthorize the current session
/// Admin token/Argon2 PHC |> The plain text token or Argon2 PHC string used to authenticate in this very same page. Changing it here will not deauthorize the current session!
admin_token: Pass, true, option;

/// Invitation organization name |> Name shown in the invitation emails that don't come from a specific organization
Expand Down Expand Up @@ -603,7 +603,7 @@ make_config! {
/// Global Duo settings (Note that users can override them)
duo: _enable_duo {
/// Enabled
_enable_duo: bool, true, def, false;
_enable_duo: bool, true, def, true;
/// Integration Key
duo_ikey: String, true, option;
/// Secret Key
Expand Down
4 changes: 2 additions & 2 deletions src/static/scripts/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ img {
min-width: 85px;
max-width: 85px;
}
#users-table .vw-ciphers, #orgs-table .vw-users, #orgs-table .vw-ciphers {
#users-table .vw-entries, #orgs-table .vw-users, #orgs-table .vw-entries {
min-width: 35px;
max-width: 40px;
}
Expand Down Expand Up @@ -53,4 +53,4 @@ img {
}
.vw-copy-toast {
width: 15rem;
}
}
13 changes: 7 additions & 6 deletions src/static/scripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
/* exported BASE_URL, _post */

function getBaseUrl() {
// If the base URL is `https://vaultwarden.example.com/base/path/`,
// If the base URL is `https://vaultwarden.example.com/base/path/admin/`,
// `window.location.href` should have one of the following forms:
//
// - `https://vaultwarden.example.com/base/path/`
// - `https://vaultwarden.example.com/base/path/#/some/route[?queryParam=...]`
// - `https://vaultwarden.example.com/base/path/admin`
// - `https://vaultwarden.example.com/base/path/admin/#/some/route[?queryParam=...]`
//
// We want to get to just `https://vaultwarden.example.com/base/path`.
const baseUrl = window.location.href;
const adminPos = baseUrl.indexOf("/admin");
return baseUrl.substring(0, adminPos != -1 ? adminPos : baseUrl.length);
const pathname = window.location.pathname;
const adminPos = pathname.indexOf("/admin");
const newPathname = pathname.substring(0, adminPos != -1 ? adminPos : pathname.length);
return `${window.location.origin}${newPathname}`;
}
const BASE_URL = getBaseUrl();

Expand Down
15 changes: 9 additions & 6 deletions src/static/scripts/datatables.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*
* To rebuild or modify this file with the latest versions of the included
* software please visit:
* https://datatables.net/download/#bs5/dt-1.13.2
* https://datatables.net/download/#bs5/dt-1.13.4
*
* Included libraries:
* DataTables 1.13.2
* DataTables 1.13.4
*/

@charset "UTF-8";
Expand Down Expand Up @@ -79,6 +79,7 @@ table.dataTable thead > tr > td.sorting_asc_disabled:before,
table.dataTable thead > tr > td.sorting_desc_disabled:before {
bottom: 50%;
content: "▲";
content: "▲"/"";
}
table.dataTable thead > tr > th.sorting:after, table.dataTable thead > tr > th.sorting_asc:after, table.dataTable thead > tr > th.sorting_desc:after, table.dataTable thead > tr > th.sorting_asc_disabled:after, table.dataTable thead > tr > th.sorting_desc_disabled:after,
table.dataTable thead > tr > td.sorting:after,
Expand All @@ -88,6 +89,7 @@ table.dataTable thead > tr > td.sorting_asc_disabled:after,
table.dataTable thead > tr > td.sorting_desc_disabled:after {
top: 50%;
content: "▼";
content: "▼"/"";
}
table.dataTable thead > tr > th.sorting_asc:before, table.dataTable thead > tr > th.sorting_desc:after,
table.dataTable thead > tr > td.sorting_asc:before,
Expand All @@ -104,9 +106,9 @@ table.dataTable thead > tr > td:active {
outline: none;
}

div.dataTables_scrollBody table.dataTable thead > tr > th:before, div.dataTables_scrollBody table.dataTable thead > tr > th:after,
div.dataTables_scrollBody table.dataTable thead > tr > td:before,
div.dataTables_scrollBody table.dataTable thead > tr > td:after {
div.dataTables_scrollBody > table.dataTable > thead > tr > th:before, div.dataTables_scrollBody > table.dataTable > thead > tr > th:after,
div.dataTables_scrollBody > table.dataTable > thead > tr > td:before,
div.dataTables_scrollBody > table.dataTable > thead > tr > td:after {
display: none;
}

Expand All @@ -132,7 +134,8 @@ div.dataTables_processing > div:last-child > div {
width: 13px;
height: 13px;
border-radius: 50%;
background: 13 110 253;
background: rgb(13, 110, 253);
background: rgb(var(--dt-row-selected));
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
div.dataTables_processing > div:last-child > div:nth-child(1) {
Expand Down
137 changes: 101 additions & 36 deletions src/static/scripts/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
*
* To rebuild or modify this file with the latest versions of the included
* software please visit:
* https://datatables.net/download/#bs5/dt-1.13.2
* https://datatables.net/download/#bs5/dt-1.13.4
*
* Included libraries:
* DataTables 1.13.2
* DataTables 1.13.4
*/

/*! DataTables 1.13.2
/*! DataTables 1.13.4
* ©2008-2023 SpryMedia Ltd - datatables.net/license
*/

/**
* @summary DataTables
* @description Paginate, search and order HTML tables
* @version 1.13.2
* @version 1.13.4
* @author SpryMedia Ltd
* @contact www.datatables.net
* @copyright SpryMedia Ltd.
Expand Down Expand Up @@ -46,21 +46,28 @@
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
// jQuery's factory checks for a global window - if it isn't present then it
// returns a factory function that expects the window object
var jq = require('jquery');

if ( ! $ ) {
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
require('jquery') :
require('jquery')( root );
}
if (typeof window !== 'undefined') {
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}

return factory( $, root, root.document );
};
if ( ! $ ) {
$ = jq( root );
}

return factory( $, root, root.document );
};
}
else {
return factory( jq, window, window.document );
}
}
else {
// Browser
Expand All @@ -73,6 +80,12 @@

var DataTable = function ( selector, options )
{
// Check if called with a window or jQuery object for DOM less applications
// This is for backwards compatibility
if (DataTable.factory(selector, options)) {
return DataTable;
}

// When creating with `new`, create a new DataTable, returning the API instance
if (this instanceof DataTable) {
return $(selector).DataTable(options);
Expand Down Expand Up @@ -1177,6 +1190,7 @@
type: sort !== null ? i+'.@data-'+sort : undefined,
filter: filter !== null ? i+'.@data-'+filter : undefined
};
col._isArrayHost = true;

_fnColumnOptions( oSettings, i );
}
Expand Down Expand Up @@ -2365,7 +2379,7 @@

// Indicate if DataTables should read DOM data as an object or array
// Used in _fnGetRowElements
if ( typeof mDataSrc !== 'number' ) {
if ( typeof mDataSrc !== 'number' && ! oCol._isArrayHost ) {
oSettings._rowReadObject = true;
}

Expand Down Expand Up @@ -5119,7 +5133,8 @@
{
return $('<div/>', {
'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
'class': settings.oClasses.sProcessing
'class': settings.oClasses.sProcessing,
'role': 'status'
} )
.html( settings.oLanguage.sProcessing )
.append('<div><div></div><div></div><div></div><div></div></div>')
Expand Down Expand Up @@ -9367,6 +9382,48 @@



/**
* Set the jQuery or window object to be used by DataTables
*
* @param {*} module Library / container object
* @param {string} type Library or container type `lib` or `win`.
*/
DataTable.use = function (module, type) {
if (type === 'lib' || module.fn) {
$ = module;
}
else if (type == 'win' || module.document) {
window = module;
document = module.document;
}
}

/**
* CommonJS factory function pass through. This will check if the arguments
* given are a window object or a jQuery object. If so they are set
* accordingly.
* @param {*} root Window
* @param {*} jq jQUery
* @returns {boolean} Indicator
*/
DataTable.factory = function (root, jq) {
var is = false;

// Test if the first parameter is a window object
if (root && root.document) {
window = root;
document = root.document;
}

// Test if the second parameter is a jQuery object
if (jq && jq.fn && jq.fn.jquery) {
$ = jq;
is = true;
}

return is;
}

/**
* Provide a common method for plug-ins to check the version of DataTables being
* used, in order to ensure compatibility.
Expand Down Expand Up @@ -9708,7 +9765,7 @@
* @type string
* @default Version number
*/
DataTable.version = "1.13.2";
DataTable.version = "1.13.4";

/**
* Private data store, containing all of the settings objects that are
Expand Down Expand Up @@ -14132,7 +14189,7 @@
*
* @type string
*/
build:"bs5/dt-1.13.2",
build:"bs5/dt-1.13.4",


/**
Expand Down Expand Up @@ -15654,25 +15711,33 @@
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}

if ( ! $ ) {
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
require('jquery') :
require('jquery')( root );
}

var jq = require('jquery');
var cjsRequires = function (root, $) {
if ( ! $.fn.dataTable ) {
require('datatables.net')(root, $);
}

return factory( $, root, root.document );
};

if (typeof window !== 'undefined') {
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}

if ( ! $ ) {
$ = jq( root );
}

cjsRequires( root, $ );
return factory( $, root, root.document );
};
}
else {
cjsRequires( window, jq );
module.exports = factory( jq, window, window.document );
}
}
else {
// Browser
Expand Down
Loading