mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-10-31 22:47:05 +01:00
doorlockd: add simulation mode
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
bccd9432af
commit
67879a659d
@ -1,3 +1,2 @@
|
|||||||
- Connect to LDAP
|
- Connect to LDAP
|
||||||
- Add 'demo' mode
|
|
||||||
- Add support for post/pre lock/unlock hooks
|
- Add support for post/pre lock/unlock hooks
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
SIMULATE = True
|
||||||
SECRET_KEY = 'foobar'
|
SECRET_KEY = 'foobar'
|
||||||
|
|
||||||
BOOTSTRAP_SERVE_LOCAL = True
|
BOOTSTRAP_SERVE_LOCAL = True
|
||||||
|
@ -57,6 +57,8 @@ webapp = Flask(__name__)
|
|||||||
webapp.config.from_pyfile('config.cfg')
|
webapp.config.from_pyfile('config.cfg')
|
||||||
socketio = SocketIO(webapp, async_mode=None)
|
socketio = SocketIO(webapp, async_mode=None)
|
||||||
Bootstrap(webapp)
|
Bootstrap(webapp)
|
||||||
|
serial_port = webapp.config.get('SERIAL_PORT')
|
||||||
|
simulate = webapp.config.get('SIMULATE')
|
||||||
|
|
||||||
# copied from sudo
|
# copied from sudo
|
||||||
eperm_insults = {
|
eperm_insults = {
|
||||||
@ -134,6 +136,9 @@ class DoorHandler:
|
|||||||
state = DoorState.Close
|
state = DoorState.Close
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
|
if simulate:
|
||||||
|
return
|
||||||
|
|
||||||
self.serial = Serial(device, baudrate=9600, bytesize=8, parity='N',
|
self.serial = Serial(device, baudrate=9600, bytesize=8, parity='N',
|
||||||
stopbits=1, timeout=1)
|
stopbits=1, timeout=1)
|
||||||
self.thread = Thread(target=self.thread_worker)
|
self.thread = Thread(target=self.thread_worker)
|
||||||
@ -178,11 +183,14 @@ class DoorHandler:
|
|||||||
|
|
||||||
class Logic:
|
class Logic:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.door_handler = DoorHandler(webapp.config.get('SERIAL_PORT'))
|
self.door_handler = DoorHandler(serial_port)
|
||||||
|
|
||||||
def _try_auth_ldap(self, user, password):
|
def _try_auth_ldap(self, user, password):
|
||||||
|
if simulate:
|
||||||
|
log.info('SIMULATION MODE! ACCEPTING ANYTHING!')
|
||||||
|
return LogicResponse.Success
|
||||||
|
|
||||||
log.info('Trying to LDAP auth (user, password) as user %s', user)
|
log.info('Trying to LDAP auth (user, password) as user %s', user)
|
||||||
return LogicResponse.Success
|
|
||||||
return LogicResponse.LDAP
|
return LogicResponse.LDAP
|
||||||
|
|
||||||
def try_auth(self, credentials):
|
def try_auth(self, credentials):
|
||||||
|
Loading…
Reference in New Issue
Block a user