Add rudimentary password data protection
This commit is contained in:
parent
e79cdb3e24
commit
a73b9d6cdf
|
@ -8,3 +8,8 @@ db_file = db.json
|
||||||
# Col1: First Name(s), Col2: Last Name(s), Col3 (optional): EMail
|
# Col1: First Name(s), Col2: Last Name(s), Col3 (optional): EMail
|
||||||
# Remove or leave empty for no check
|
# Remove or leave empty for no check
|
||||||
name_file = namensliste.csv
|
name_file = namensliste.csv
|
||||||
|
|
||||||
|
|
||||||
|
# Username and password for data retrieval
|
||||||
|
admin_user = admin
|
||||||
|
admin_pass = topSecret
|
||||||
|
|
|
@ -94,3 +94,18 @@ def post_departure():
|
||||||
)
|
)
|
||||||
|
|
||||||
return 'OK', 200
|
return 'OK', 200
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/data')
|
||||||
|
def get_data():
|
||||||
|
|
||||||
|
if not 'Authorization' in request.headers:
|
||||||
|
return 'Error: No Authorization', 401, {'WWW-Authenticate': 'Basic'}
|
||||||
|
|
||||||
|
if request.authorization.username != config['admin_user']:
|
||||||
|
return "Wrong username", 403
|
||||||
|
|
||||||
|
if request.authorization.password != config['admin_pass']:
|
||||||
|
return "Wrong password", 403
|
||||||
|
|
||||||
|
return json.dumps(db.all(), indent=4), 200
|
||||||
|
|
Loading…
Reference in New Issue