templating - auth basic support
This commit is contained in:
parent
289ad106cb
commit
23aa053003
@ -1,2 +1,2 @@
|
|||||||
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
||||||
auth_basic_user_file {{ NGINX_PREFIX }}.htpasswd;
|
auth_basic_user_file {{ NGINX_PREFIX }}htpasswd;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
location {{ AUTH_BASIC_LOCATION }} {
|
location {{ AUTH_BASIC_LOCATION }} {
|
||||||
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
auth_basic "{{ AUTH_BASIC_TEXT }}";
|
||||||
auth_basic_user_file {{ NGINX_PREFIX }}.htpasswd;
|
auth_basic_user_file {{ NGINX_PREFIX }}htpasswd;
|
||||||
}
|
}
|
||||||
|
|||||||
3
confs2/site/htpasswd
Normal file
3
confs2/site/htpasswd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{% if USE_AUTH_BASIC == "yes" %}
|
||||||
|
{{ AUTH_BASIC_USER }}:{{ sha512_crypt(AUTH_BASIC_PASSWORD) }}
|
||||||
|
{% endif %}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import jinja2, glob, os, pathlib, copy
|
import jinja2, glob, os, pathlib, copy, crypt
|
||||||
|
|
||||||
class Templator :
|
class Templator :
|
||||||
|
|
||||||
@ -30,11 +30,15 @@ class Templator :
|
|||||||
real_config["NGINX_PREFIX"] = self.__target_path
|
real_config["NGINX_PREFIX"] = self.__target_path
|
||||||
if real_config["MULTISITE"] == "yes" and type == "site" :
|
if real_config["MULTISITE"] == "yes" and type == "site" :
|
||||||
real_config["NGINX_PREFIX"] += first_server + "/"
|
real_config["NGINX_PREFIX"] += first_server + "/"
|
||||||
|
for variable, value in self.__config.items() :
|
||||||
|
if variable.startswith(first_server + "_") :
|
||||||
|
real_config[variable.replace(first_server + "_", "", 1)] = value
|
||||||
for filename in glob.iglob(self.__input_path + "/" + type + "**/**", recursive=True) :
|
for filename in glob.iglob(self.__input_path + "/" + type + "**/**", recursive=True) :
|
||||||
if os.path.isfile(filename) :
|
if os.path.isfile(filename) :
|
||||||
relative_filename = filename.replace(self.__input_path, "").replace(type + "/", "")
|
relative_filename = filename.replace(self.__input_path, "").replace(type + "/", "")
|
||||||
template = self.__template_env.get_template(type + "/" + relative_filename)
|
template = self.__template_env.get_template(type + "/" + relative_filename)
|
||||||
template.globals["has_value"] = Templator.has_value
|
template.globals["has_value"] = Templator.has_value
|
||||||
|
template.globals["sha512_crypt"] = Templator.sha512_crypt
|
||||||
output = template.render(real_config, all=real_config)
|
output = template.render(real_config, all=real_config)
|
||||||
if real_config["MULTISITE"] == "yes" and type == "site" :
|
if real_config["MULTISITE"] == "yes" and type == "site" :
|
||||||
relative_filename = first_server + "/" + relative_filename
|
relative_filename = first_server + "/" + relative_filename
|
||||||
@ -50,3 +54,6 @@ class Templator :
|
|||||||
if (k == name or k.endswith("_" + name)) and v == value :
|
if (k == name or k.endswith("_" + name)) and v == value :
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def sha512_crypt(password) :
|
||||||
|
return crypt.crypt(password, crypt.mksalt(crypt.METHOD_SHA512))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user