From f5603272d22edca1f97f6166f5e8da3d143339b8 Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Tue, 18 Sep 2018 01:02:44 +0200 Subject: [PATCH] doorlockd: frontend: support local authentication Signed-off-by: Ralf Ramsauer --- doorlockd | 10 +++++++++- share/doorlockd/templates/index.html | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doorlockd b/doorlockd index 7ed1d8d..a4d6b9a 100755 --- a/doorlockd +++ b/doorlockd @@ -408,6 +408,7 @@ class Logic: class AuthenticationForm(FlaskForm): username = StringField('Username', [Length(min=3, max=25)]) password = PasswordField('Password', [DataRequired()]) + method = StringField('Method', [DataRequired()]) open = SubmitField('Open') present = SubmitField('Present') close = SubmitField('Close') @@ -425,6 +426,11 @@ class AuthenticationForm(FlaskForm): elif self.present.data: self.desired_state = DoorState.Present + if self.method.data == 'Local': + self.method = AuthMethod.LOCAL_USER_DB + else: # default: use LDAP + self.method = AuthMethod.LDAP_USER_PW + return True @@ -500,9 +506,11 @@ def home(): if request.method == 'POST' and authentication_form.validate(): user = authentication_form.username.data password = authentication_form.password.data - credentials = AuthMethod.LDAP_USER_PW, user, password + method = authentication_form.method + credentials = method, user, password log.info('Incoming request from %s' % user.encode('utf-8')) + log.info(' authentication method: %s' % method) desired_state = authentication_form.desired_state log.info(' desired state: %s' % desired_state) log.info(' current state: %s' % logic.state) diff --git a/share/doorlockd/templates/index.html b/share/doorlockd/templates/index.html index 0d755a4..5e88590 100644 --- a/share/doorlockd/templates/index.html +++ b/share/doorlockd/templates/index.html @@ -19,10 +19,17 @@ -
+
+
+ + +