diff options
author | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-12-24 01:49:32 +0300 |
---|---|---|
committer | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-12-24 01:49:32 +0300 |
commit | 436c1d930d154af7bda9a93f3a6b83cd85656d17 (patch) | |
tree | 8cf15679754f6abdf5bad393fa519a316a24aef1 | |
parent | 63cd9d330ebb4735cab16750e3be6edf3911cbca (diff) |
Setting crypto params from admin panel initial impl
-rw-r--r-- | appinfo/routes.php | 5 | ||||
-rw-r--r-- | js/settings.js | 38 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 32 |
3 files changed, 74 insertions, 1 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 8224fa4..dde5395 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -61,6 +61,11 @@ $application->registerRoutes( "url" => "/settings/autocomplete/table/group", "verb" => "POST" ], + [ + "name" => "settings#cryptoParams", + "url" => "/settings/crypto/params", + "verb" => "GET" + ], ] ] ); diff --git a/js/settings.js b/js/settings.js index 0a42eaf..a0f6b14 100644 --- a/js/settings.js +++ b/js/settings.js @@ -58,6 +58,40 @@ user_sql.adminSettingsUI = function () { }); }; + var cryptoParams = function () { + var cryptoChanged = function () { + var div = $("#opt-crypto_params"); + div.empty(); + + var cryptoClass = $("#opt-crypto_class").val(); + $.get(OC.generateUrl("/apps/user_sql/settings/crypto/params"), cryptoClass, function (data) { + if (data.status === "success") { + for (var index = 0, length = data.data.length; index < length; ++index) { + div.append("<div><label for=\"opt-crypto_param_" + + index + + "\"><span>" + + data.data[index]["visible_name"] + + "</span><input type=\"number\" id=\"opt-crypto_param_" + + index + + "\" name=\"opt-crypto_param_" + + index + + "\" step=\"1\" min=\"" + + data.data[index]["min"] + + "\" max=\"" + + data.data[index]["max"] + + "\" value=\"" + + data.data[index]["default"] // TODO set current + + "\"></label></div>"); + } + } + }, "json"); + }; + $("#opt-crypto_class").change(function () { + cryptoChanged(); + }); + cryptoChanged(); + }; + $("#user_sql-db_connection_verify").click(function (event) { return click(event, "/apps/user_sql/settings/db/verify"); }); @@ -89,6 +123,8 @@ user_sql.adminSettingsUI = function () { "#db-table-group-column-admin, #db-table-group-column-name, #db-table-group-column-gid", "/apps/user_sql/settings/autocomplete/table/group" ); + + cryptoParams(); } }; @@ -96,4 +132,4 @@ $(document).ready(function () { if ($(form_id)) { user_sql.adminSettingsUI(); } -});
\ No newline at end of file +}); diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index a192daf..a590a08 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -367,4 +367,36 @@ class SettingsController extends Controller return $columns; } + + /** + * TODO + * + * @return array TODO + */ + public function cryptoParams() + { + // TODO implement + // TODO add current values + return [ + "status" => "success", + "data" => [ + [ + "name" => "memoryCost", + "visible_name" => "Memory cost (KiB)", + "default" => PASSWORD_ARGON2_DEFAULT_MEMORY_COST, + "min" => 1, "max" => 1048576 + ], + [ + "name" => "timeCost", "visible_name" => "Time cost", + "default" => PASSWORD_ARGON2_DEFAULT_TIME_COST, "min" => 1, + "max" => 1024 + ], + [ + "name" => "threads", "visible_name" => "Threads", + "default" => PASSWORD_ARGON2_DEFAULT_THREADS, "min" => 1, + "max" => 1024 + ] + ] + ]; + } } |