mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
change domain validation scheme
This commit is contained in:
10
install.sh
10
install.sh
@@ -11,19 +11,23 @@ if [ "$ID" = "ubuntu" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then
|
|||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt -q -y -o Dpkg::Options::=--force-confnew update
|
apt -q -y -o Dpkg::Options::=--force-confnew update
|
||||||
apt -q -y -o Dpkg::Options::=--force-confnew install wget curl
|
apt -q -y -o Dpkg::Options::=--force-confnew install wget curl
|
||||||
SERVER_OS="$NAME"
|
SERVER_OS="Ubuntu"
|
||||||
elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then
|
elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then
|
||||||
case "$VERSION_ID" in
|
case "$VERSION_ID" in
|
||||||
7|7.*)
|
7|7.*)
|
||||||
yum install curl wget -y 1> /dev/null
|
yum install curl wget -y 1> /dev/null
|
||||||
yum update curl wget ca-certificates -y 1> /dev/null
|
yum update curl wget ca-certificates -y 1> /dev/null
|
||||||
SERVER_OS="$NAME"
|
if [ "$ID" = "centos" ]; then
|
||||||
|
SERVER_OS="CentOS"
|
||||||
|
else
|
||||||
|
SERVER_OS="CloudLinux"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
8|8.*)
|
8|8.*)
|
||||||
printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n'
|
printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n'
|
||||||
yum install curl wget -y 1> /dev/null
|
yum install curl wget -y 1> /dev/null
|
||||||
yum update curl wget ca-certificates -y 1> /dev/null
|
yum update curl wget ca-certificates -y 1> /dev/null
|
||||||
SERVER_OS="${NAME}${VERSION_ID}"
|
SERVER_OS="CentOS8"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -63,3 +63,4 @@ websocket-client==0.56.0
|
|||||||
zope.component==4.4.1
|
zope.component==4.4.1
|
||||||
zope.event==4.3.0
|
zope.event==4.3.0
|
||||||
zope.interface==4.5.0
|
zope.interface==4.5.0
|
||||||
|
validators==0.14.2
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ from managePHP.phpManager import PHPManager
|
|||||||
from ApachController.ApacheVhosts import ApacheVhost
|
from ApachController.ApacheVhosts import ApacheVhost
|
||||||
from plogical.vhostConfs import vhostConfs
|
from plogical.vhostConfs import vhostConfs
|
||||||
from plogical.cronUtil import CronUtil
|
from plogical.cronUtil import CronUtil
|
||||||
from re import match,I,M
|
|
||||||
from plogical import randomPassword
|
from plogical import randomPassword
|
||||||
from .StagingSetup import StagingSetup
|
from .StagingSetup import StagingSetup
|
||||||
|
import validators
|
||||||
|
|
||||||
|
|
||||||
class WebsiteManager:
|
class WebsiteManager:
|
||||||
@@ -180,14 +180,13 @@ class WebsiteManager:
|
|||||||
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
|
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
|
||||||
|
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
|
|
||||||
M | I):
|
if not validators.domain(domain):
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
if not match(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', adminEmail,
|
if not validators.email(adminEmail):
|
||||||
M | I):
|
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -267,8 +266,8 @@ class WebsiteManager:
|
|||||||
path = data['path']
|
path = data['path']
|
||||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
|
|
||||||
M | I):
|
if not validators.domain(domain):
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -1635,8 +1634,7 @@ class WebsiteManager:
|
|||||||
aliasDomain = data['aliasDomain']
|
aliasDomain = data['aliasDomain']
|
||||||
ssl = data['ssl']
|
ssl = data['ssl']
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', aliasDomain,
|
if not validators.domain(aliasDomain):
|
||||||
M | I):
|
|
||||||
data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -2725,14 +2723,14 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
self.domain = data['masterDomain']
|
self.domain = data['masterDomain']
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', self.domain,
|
|
||||||
M | I):
|
if not validators.domain(self.domain):
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['domainName'],
|
|
||||||
M | I):
|
if not validators.domain(data['domainName']):
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -2798,8 +2796,8 @@ StrictHostKeyChecking no
|
|||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['childDomain'],
|
|
||||||
M | I):
|
if not validators.domain(data['childDomain']):
|
||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user