Allow selection of default authentication backend

This commit is contained in:
Kishi85 2018-11-19 21:40:20 +01:00
parent 1914b5f577
commit 5fa8760efd
3 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,6 @@
[doorlock]
# Authentication Backends
# DEFAULT_BACKEND=LDAP
# LDAP
# LDAP_URI = ldaps://ldap1.binary.kitchen

View File

@ -157,9 +157,13 @@ def home():
# Don't trust python, zero credentials
user = password = credentials = None
auth_backends=[{"backend":b,
"selected":(b==default_backend)}
for b in logic.auth.backends]
return render_template('index.html',
authentication_form=authentication_form,
auth_backends=logic.auth.backends,
auth_backends=auth_backends,
response=response,
state_text=str(logic.state),
led=logic.state.to_img(),
@ -188,6 +192,9 @@ def webapp_run(cfg, my_logic, status, version, template_folder, static_folder):
global html_title
html_title = '%s (%s - v%s)' % (title, status, version)
global default_backend
default_backend = cfg.str('DEFAULT_BACKEND')
webapp.config['SECRET_KEY'] = cfg.str('SECRET_KEY')
webapp.template_folder = template_folder
webapp.static_folder = static_folder

View File

@ -26,8 +26,8 @@
<div class="form-group">
<label for="method">Authentication method</label>
<select name="method" id="method" class="form-control">
{% for backend in auth_backends %}
<option>{{ backend }}</option>
{% for backend, selected in auth_backends|sort(attribute="backend") %}
<option{% if selected %} selected{% endif %}>{{ backend }}</option>
{% endfor %}
</select>
</div>