Skip to content

Commit a719b6d

Browse files
committed
Merge branch 'master' of github.com:serghey-rodin/vesta
2 parents 9de2d15 + 70548e7 commit a719b6d

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

bin/v-generate-api-key

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# info: generate api key
3+
# options: none
4+
#
5+
# The function creates a key file in /usr/local/vesta/data/keys/
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
keygen()
13+
{
14+
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
15+
}
16+
KEYS='/usr/local/vesta/data/keys/'
17+
HASH=$(keygen)
18+
19+
20+
#----------------------------------------------------------#
21+
# Action #
22+
#----------------------------------------------------------#
23+
24+
if [ ! -d ${KEYS} ]; then
25+
mkdir ${KEYS}
26+
fi
27+
28+
if [[ -e ${KEYS}${HASH} ]] ; then
29+
while [[ -e ${KEYS}${HASH} ]] ; do
30+
HASH=$(keygen)
31+
done
32+
fi
33+
34+
touch ${KEYS}${HASH}
35+
echo ${HASH}
36+
37+
#----------------------------------------------------------#
38+
# Vesta #
39+
#----------------------------------------------------------#
40+
41+
exit

install/debian/firewall/ports.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ PROTOCOL='TCP' PORT='5432'
1313
PROTOCOL='TCP' PORT='8080'
1414
PROTOCOL='TCP' PORT='8443'
1515
PROTOCOL='TCP' PORT='8083'
16+
PROTOCOL='TCP' PORT='12000:12100'

install/rhel/firewall/ports.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ PROTOCOL='TCP' PORT='5432'
1313
PROTOCOL='TCP' PORT='8080'
1414
PROTOCOL='TCP' PORT='8443'
1515
PROTOCOL='TCP' PORT='8083'
16+
PROTOCOL='TCP' PORT='12000:12100'

install/ubuntu/firewall/ports.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ PROTOCOL='TCP' PORT='5432'
1313
PROTOCOL='TCP' PORT='8080'
1414
PROTOCOL='TCP' PORT='8443'
1515
PROTOCOL='TCP' PORT='8083'
16+
PROTOCOL='TCP' PORT='12000:12100'

web/api/index.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
// Authentication
77
$auth_code = 1;
88
if (empty($_POST['hash'])) {
9+
// Check user permission to use API
10+
if ($_POST['user'] != 'admin') {
11+
echo 'Error: only admin is allowed to use API';
12+
exit;
13+
}
14+
915
$v_user = escapeshellarg($_POST['user']);
1016
$v_password = escapeshellarg($_POST['password']);
1117
exec(VESTA_CMD ."v-check-user-password ".$v_user." ".$v_password." '".$_SERVER["REMOTE_ADDR"]."'", $output, $auth_code);
@@ -20,13 +26,6 @@
2026
echo 'Error: authentication failed';
2127
exit;
2228
}
23-
24-
// Check user permission to use API
25-
if ($_POST['user'] != 'admin') {
26-
echo 'Error: only admin is allowed to use API';
27-
exit;
28-
}
29-
3029

3130
// Prepare arguments
3231
if (isset($_POST['cmd'])) $cmd = escapeshellarg($_POST['cmd']);

0 commit comments

Comments
 (0)