set token

This commit is contained in:
Michael Grote 2023-04-13 12:19:18 +02:00
parent 33f05f8b14
commit f9dda355fb
2 changed files with 3 additions and 3 deletions

4
app.py
View file

@ -9,7 +9,7 @@ app.config['MAX_CONTENT_LENGTH'] = int(os.environ.get('MAX_CONTENT_LENGTH', '5')
VALID_FILENAME_REGEX = r'^[a-zA-Z0-9\-_\.]+$'
UPLOAD_TOKEN = os.environ.get('UPLOAD_TOKEN', 'myuploadotken')
AUTH_TOKEN = os.environ.get('AUTH_TOKEN', 'myauthtoken')
def is_valid_filename(filename):
return bool(re.match(VALID_FILENAME_REGEX, filename))
@ -22,7 +22,7 @@ def upload_file():
if 'token' not in request.headers:
return jsonify({'error': 'No token supplied'}), 401
if request.headers['token'] != UPLOAD_TOKEN:
if request.headers['token'] != AUTH_TOKEN:
return jsonify({'error': 'Invalid token supplied'}), 401
file = request.files['file']

View file

@ -10,4 +10,4 @@ services:
FLASK_DEBUG: 1
FLASK_APP: app
UPLOAD_DIRECTORY: /uploads
UPLOAD_TOKEN: myuploadtoken
AUTH_TOKEN: myuploadtoken