1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

doorlockd: frontend: support local authentication

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2018-09-18 01:02:44 +02:00
parent 45724f37c8
commit f5603272d2
2 changed files with 17 additions and 2 deletions

View File

@ -408,6 +408,7 @@ class Logic:
class AuthenticationForm(FlaskForm): class AuthenticationForm(FlaskForm):
username = StringField('Username', [Length(min=3, max=25)]) username = StringField('Username', [Length(min=3, max=25)])
password = PasswordField('Password', [DataRequired()]) password = PasswordField('Password', [DataRequired()])
method = StringField('Method', [DataRequired()])
open = SubmitField('Open') open = SubmitField('Open')
present = SubmitField('Present') present = SubmitField('Present')
close = SubmitField('Close') close = SubmitField('Close')
@ -425,6 +426,11 @@ class AuthenticationForm(FlaskForm):
elif self.present.data: elif self.present.data:
self.desired_state = DoorState.Present 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 return True
@ -500,9 +506,11 @@ def home():
if request.method == 'POST' and authentication_form.validate(): if request.method == 'POST' and authentication_form.validate():
user = authentication_form.username.data user = authentication_form.username.data
password = authentication_form.password.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('Incoming request from %s' % user.encode('utf-8'))
log.info(' authentication method: %s' % method)
desired_state = authentication_form.desired_state desired_state = authentication_form.desired_state
log.info(' desired state: %s' % desired_state) log.info(' desired state: %s' % desired_state)
log.info(' current state: %s' % logic.state) log.info(' current state: %s' % logic.state)

View File

@ -19,10 +19,17 @@
<label class="control-label" for="username">Username</label> <label class="control-label" for="username">Username</label>
<input class="form-control" id="username" name="username" type="text" value=""> <input class="form-control" id="username" name="username" type="text" value="">
</div> </div>
<div class="form-group required"> <div class="form-group required">
<label class="control-label" for="password">Password</label> <label class="control-label" for="password">Password</label>
<input class="form-control" id="password" name="password" required type="password" value=""> <input class="form-control" id="password" name="password" required type="password" value="">
</div> </div>
<div class="form-group">
<label for="method">Authentication method</label>
<select name="method" id="method" class="form-control">
<option selected>LDAP</option>
<option>Local</option>
</select>
</div>
<input class="btn btn-success btn-lg btn-block" id="open" name="open" type="submit" value="Open"> <input class="btn btn-success btn-lg btn-block" id="open" name="open" type="submit" value="Open">
<input class="btn btn-warning btn-lg btn-block" id="present" name="present" type="submit" value="Present"> <input class="btn btn-warning btn-lg btn-block" id="present" name="present" type="submit" value="Present">
<input class="btn btn-danger btn-lg btn-block" id="close" name="close" type="submit" value="Close"> <input class="btn btn-danger btn-lg btn-block" id="close" name="close" type="submit" value="Close">