@@ -0,0 +1,695 @@
+# -*- coding: utf-8 -*-%0A%0Afrom functools import wraps%0A%0Afrom flask import request%0Afrom flask import jsonify%0A%0Afrom rio.models  import validate_sender%0A%0A%0Adef require_sender(f):%0A    %22%22%22A decorator that protect emit view function is triggered by a trusted sender.%0A%0A    Currently, Rio only support Basic Authorization.%0A    %22%22%22%0A    @wraps(f)%0A    def decorator(*args, **kwargs):%0A        if not request.authorization:%0A            return jsonify(%7Bmessage='unauthorized'%7D), 401%0A%0A        username = request.authorization.username%0A        password = request.authorization.password%0A%0A        if not validate_sender(username, password):%0A            return jsonify(%7Bmessage='forbidden'%7D), 403%0A    return decorator%0A

Define `require_sender`.