added password check for DELETE method #7
@ -53,9 +53,16 @@ def create_app():
|
|||||||
|
|
||||||
@app.route('/presentation/<string:presentation>', methods=['DELETE'])
|
@app.route('/presentation/<string:presentation>', methods=['DELETE'])
|
||||||
def delete_presentation(presentation):
|
def delete_presentation(presentation):
|
||||||
|
data = request.get_json()
|
||||||
|
if not 'auth' in data or not _valid_credential(data['auth']):
|
||||||
|
return Response(response="Use correct credentials to access this endpoint", status=401)
|
||||||
|
|
||||||
shutil.rmtree(os.path.join(storagedir, presentation))
|
shutil.rmtree(os.path.join(storagedir, presentation))
|
||||||
return Response(response='Deleted {}'.format(presentation))
|
return Response(response='Deleted {}'.format(presentation))
|
||||||
|
|
||||||
|
def _valid_credential(pw):
|
||||||
|
return config['api']['password'] == pw
|
||||||
|
|
||||||
@app.route('/presentation/<string:presentation>/<path:path>')
|
@app.route('/presentation/<string:presentation>/<path:path>')
|
||||||
def serve_file(presentation, path):
|
def serve_file(presentation, path):
|
||||||
realpath = safe_join(storagedir, os.path.join(presentation, path))
|
realpath = safe_join(storagedir, os.path.join(presentation, path))
|
||||||
@ -115,7 +122,7 @@ def create_app():
|
|||||||
@app.route('/status/daemon')
|
@app.route('/status/daemon')
|
||||||
def daemon_status():
|
def daemon_status():
|
||||||
running = False
|
running = False
|
||||||
if daemon_detect.is_running():
|
if api.daemon_detect.is_running():
|
||||||
running = True
|
running = True
|
||||||
return Response(response=json.dumps({'running': running}),
|
return Response(response=json.dumps({'running': running}),
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
permission_url = https://example.com/perm
|
permission_url = https://example.com/perm
|
||||||
cache_seconds = 30
|
cache_seconds = 30
|
||||||
log_level = DEBUG
|
log_level = DEBUG
|
||||||
|
password = dummy
|
||||||
|
|
||||||
[db]
|
[db]
|
||||||
database = somedatabase
|
database = somedatabase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user