Skip to content

Commit 2693f6f

Browse files
committed
add SSH key check
1 parent 8bf49a6 commit 2693f6f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

proxstar/static/js/script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ $("#create-vm").click(function(){
267267
const max_cpu = $(this).data('max_cpu');
268268
const max_mem = $(this).data('max_mem');
269269
const max_disk = $(this).data('max_disk');
270+
var ssh_regex = new RegExp("ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?")
270271
var disk = document.getElementById('disk').value;
271272
fetch(`/template/${template}/disk`, {
272273
credentials: 'same-origin',
@@ -279,7 +280,9 @@ $("#create-vm").click(function(){
279280
return disk
280281
}).then((disk) => {
281282
if (name && disk) {
282-
if (disk > max_disk) {
283+
if (!ssh_regex.test(ssh_key)) {
284+
swal("Uh oh...", "Invalid SSH key!", "error");
285+
} else if (disk > max_disk) {
283286
swal("Uh oh...", `You do not have enough disk resources available! Please lower the VM disk size to ${max_disk}GB or lower.`, "error");
284287
} else if (template != 'none' && cores > max_cpu) {
285288
swal("Uh oh...", `You do not have enough CPU resources available! Please lower the VM cores to ${max_cpu} or lower.`, "error");

0 commit comments

Comments
 (0)