local-letsencrypt/server/utils.py

19 lines
448 B
Python
Raw Normal View History

2017-03-12 18:55:05 +00:00
from functools import wraps
from flask import current_app, request, abort
def verify_token(f):
"""Verifies request token"""
@wraps(f)
def wrapped(*args, **kwargs):
rec = request.args.get('record', None)
token = request.args.get('token', None)
if rec in current_app.config['TOKENS'] and current_app.config['TOKENS'][rec] == token:
return f(*args, **kwargs)
abort(403)
return wrapped