Move auth function to cut some lines
This commit is contained in:
parent
65f6002560
commit
250adf01cf
|
@ -0,0 +1,8 @@
|
||||||
|
# Very, very simple auth feature.
|
||||||
|
def basicauth(key, configured):
|
||||||
|
if configured == "":
|
||||||
|
return True
|
||||||
|
elif configured == key:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
12
run.py
12
run.py
|
@ -15,6 +15,7 @@ from conf import config
|
||||||
# Import QuadFile stuff
|
# Import QuadFile stuff
|
||||||
from QuadFile import db
|
from QuadFile import db
|
||||||
from QuadFile.output import print_log, time_to_string
|
from QuadFile.output import print_log, time_to_string
|
||||||
|
from QuadFile import application
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@ -53,15 +54,6 @@ def delete_old():
|
||||||
db.delete_entry(file["file"])
|
db.delete_entry(file["file"])
|
||||||
|
|
||||||
|
|
||||||
def auth(key):
|
|
||||||
if config["KEY"] == "":
|
|
||||||
return True
|
|
||||||
elif config["KEY"] == key:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def error_page(error, code):
|
def error_page(error, code):
|
||||||
return render_template('error.html', page=config["SITE_DATA"], error=error, code=code)
|
return render_template('error.html', page=config["SITE_DATA"], error=error, code=code)
|
||||||
|
|
||||||
|
@ -77,7 +69,7 @@ def allowed_file(filename):
|
||||||
def upload_file():
|
def upload_file():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print_log('Web', 'New file received')
|
print_log('Web', 'New file received')
|
||||||
if not auth(request.headers.get('X-Hyozan-Auth')):
|
if not application.auth(request.headers.get('X-Hyozan-Auth'), config["KEY"]):
|
||||||
abort(403)
|
abort(403)
|
||||||
data = dict()
|
data = dict()
|
||||||
file = request.files['file']
|
file = request.files['file']
|
||||||
|
|
Loading…
Reference in New Issue