add variable for hsts
This commit is contained in:
@@ -1162,6 +1162,12 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
currsitetype=oldsitetype,
|
currsitetype=oldsitetype,
|
||||||
currcachetype=oldcachetype,
|
currcachetype=oldcachetype,
|
||||||
webroot=wo_site_webroot)
|
webroot=wo_site_webroot)
|
||||||
|
if pargs.hsts == "on":
|
||||||
|
data['hsts'] = True
|
||||||
|
hsts = True
|
||||||
|
elif pargs.hsts == "off":
|
||||||
|
data['hsts'] = False
|
||||||
|
hsts = False
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
Log.error(self, "Cannot update {0}, Invalid Options"
|
Log.error(self, "Cannot update {0}, Invalid Options"
|
||||||
@@ -1328,12 +1334,12 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
if pargs.hsts:
|
if pargs.hsts:
|
||||||
if pargs.hsts == 'on':
|
if data['hsts'] is True:
|
||||||
if os.path.isfile(("{0}/conf/nginx/ssl.conf")
|
if os.path.isfile(("{0}/conf/nginx/ssl.conf")
|
||||||
.format(wo_site_webroot)):
|
.format(wo_site_webroot)):
|
||||||
if (not os.path.isfile("{0}/conf/nginx/hsts.conf"
|
if (not os.path.isfile("{0}/conf/nginx/hsts.conf"
|
||||||
.format(wo_site_webroot))):
|
.format(wo_site_webroot))):
|
||||||
setupHsts(self, wo_domain, True)
|
setupHsts(self, wo_domain)
|
||||||
else:
|
else:
|
||||||
Log.error(self, "HSTS is already configured for given "
|
Log.error(self, "HSTS is already configured for given "
|
||||||
"site")
|
"site")
|
||||||
@@ -1345,7 +1351,7 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
"site")
|
"site")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
elif pargs.hsts == 'off':
|
elif data['hsts'] is False:
|
||||||
if os.path.isfile(("{0}/conf/nginx/hsts.conf")
|
if os.path.isfile(("{0}/conf/nginx/hsts.conf")
|
||||||
.format(wo_site_webroot)):
|
.format(wo_site_webroot)):
|
||||||
WOFileUtils.mvfile(self, "{0}/conf/nginx/hsts.conf"
|
WOFileUtils.mvfile(self, "{0}/conf/nginx/hsts.conf"
|
||||||
|
|||||||
@@ -1453,13 +1453,13 @@ def renewLetsEncrypt(self, wo_domain_name):
|
|||||||
# redirect= False to disable https redirection
|
# redirect= False to disable https redirection
|
||||||
|
|
||||||
|
|
||||||
def setupHsts(self, wo_domain, hsts=True):
|
def setupHsts(self, wo_domain_name):
|
||||||
Log.info(
|
Log.info(
|
||||||
self, "Adding /var/www/{0}/conf/nginx/hsts.conf"
|
self, "Adding /var/www/{0}/conf/nginx/hsts.conf"
|
||||||
.format(wo_domain))
|
.format(wo_domain_name))
|
||||||
|
|
||||||
hstsconf = open("/var/www/{0}/conf/nginx/hsts.conf"
|
hstsconf = open("/var/www/{0}/conf/nginx/hsts.conf"
|
||||||
.format(wo_domain),
|
.format(wo_domain_name),
|
||||||
encoding='utf-8', mode='w')
|
encoding='utf-8', mode='w')
|
||||||
hstsconf.write("more_set_headers "
|
hstsconf.write("more_set_headers "
|
||||||
"\"Strict-Transport-Security: "
|
"\"Strict-Transport-Security: "
|
||||||
|
|||||||
Reference in New Issue
Block a user