Skip to content

Commit 436c1d9

Browse files
committed
Setting crypto params from admin panel initial impl
1 parent 63cd9d3 commit 436c1d9

3 files changed

Lines changed: 74 additions & 1 deletion

File tree

appinfo/routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
"url" => "/settings/autocomplete/table/group",
6262
"verb" => "POST"
6363
],
64+
[
65+
"name" => "settings#cryptoParams",
66+
"url" => "/settings/crypto/params",
67+
"verb" => "GET"
68+
],
6469
]
6570
]
6671
);

js/settings.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,40 @@ user_sql.adminSettingsUI = function () {
5858
});
5959
};
6060

61+
var cryptoParams = function () {
62+
var cryptoChanged = function () {
63+
var div = $("#opt-crypto_params");
64+
div.empty();
65+
66+
var cryptoClass = $("#opt-crypto_class").val();
67+
$.get(OC.generateUrl("/apps/user_sql/settings/crypto/params"), cryptoClass, function (data) {
68+
if (data.status === "success") {
69+
for (var index = 0, length = data.data.length; index < length; ++index) {
70+
div.append("<div><label for=\"opt-crypto_param_"
71+
+ index
72+
+ "\"><span>"
73+
+ data.data[index]["visible_name"]
74+
+ "</span><input type=\"number\" id=\"opt-crypto_param_"
75+
+ index
76+
+ "\" name=\"opt-crypto_param_"
77+
+ index
78+
+ "\" step=\"1\" min=\""
79+
+ data.data[index]["min"]
80+
+ "\" max=\""
81+
+ data.data[index]["max"]
82+
+ "\" value=\""
83+
+ data.data[index]["default"] // TODO set current
84+
+ "\"></label></div>");
85+
}
86+
}
87+
}, "json");
88+
};
89+
$("#opt-crypto_class").change(function () {
90+
cryptoChanged();
91+
});
92+
cryptoChanged();
93+
};
94+
6195
$("#user_sql-db_connection_verify").click(function (event) {
6296
return click(event, "/apps/user_sql/settings/db/verify");
6397
});
@@ -89,11 +123,13 @@ user_sql.adminSettingsUI = function () {
89123
"#db-table-group-column-admin, #db-table-group-column-name, #db-table-group-column-gid",
90124
"/apps/user_sql/settings/autocomplete/table/group"
91125
);
126+
127+
cryptoParams();
92128
}
93129
};
94130

95131
$(document).ready(function () {
96132
if ($(form_id)) {
97133
user_sql.adminSettingsUI();
98134
}
99-
});
135+
});

lib/Controller/SettingsController.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,36 @@ public function groupTableAutocomplete()
367367

368368
return $columns;
369369
}
370+
371+
/**
372+
* TODO
373+
*
374+
* @return array TODO
375+
*/
376+
public function cryptoParams()
377+
{
378+
// TODO implement
379+
// TODO add current values
380+
return [
381+
"status" => "success",
382+
"data" => [
383+
[
384+
"name" => "memoryCost",
385+
"visible_name" => "Memory cost (KiB)",
386+
"default" => PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
387+
"min" => 1, "max" => 1048576
388+
],
389+
[
390+
"name" => "timeCost", "visible_name" => "Time cost",
391+
"default" => PASSWORD_ARGON2_DEFAULT_TIME_COST, "min" => 1,
392+
"max" => 1024
393+
],
394+
[
395+
"name" => "threads", "visible_name" => "Threads",
396+
"default" => PASSWORD_ARGON2_DEFAULT_THREADS, "min" => 1,
397+
"max" => 1024
398+
]
399+
]
400+
];
401+
}
370402
}

0 commit comments

Comments
 (0)