ALLOWS_INSTANCE = /^([A-Za-z_]\w*)[ \t]*(?::[^=\n]+)?=[ \t]*([A-Za-z_][\w.]*)[ \t]*\(/m
flask-allows: @allows.requires(IsAdmin, ...) on an allows = Allows(...) instance, @fa.requires(...) on the module, or a bare
@requires(...) bound to flask_allows' (or its flask_allows2 fork,
FlaskBB's) by this file's imports, aliases included, refuses (403, or
the on_fail handler) a caller whose identity fails the
requirements: an authorization check. A project's own requires
decides nothing here, nor do requirements that only negate
(requires(Not(...))); Not negates only its own argument.
AUTHZ_CALL = /\b(?:has_\w*perm\w*|check_access|CheckAccess)\b/
What an authorization check decides on, as opposed to a feature flag or
a quota: a permission-check call, or a role / permission / ownership
field tested in a condition. Only the condition counts for a field:
Dify's token decorators query TenantAccountJoin.role == "owner" to
find the tenant owner, which checks nothing about the caller.
DECORATOR_PATTERNS = [{/\@login_required/, "flask-login login_required"}, {/\@roles_required\s*\(/, "flask-security roles_required"}, {/\@roles_accepted\s*\(/, "flask-security roles_accepted"}, {/\@jwt_required\b/, "flask-jwt-extended jwt_required"}, {/\@jwt_optional\s*\(/, "flask-jwt-extended jwt_optional"}, {/\@fresh_jwt_required\s*\(/, "flask-jwt-extended fresh_jwt_required"}, {/\@auth_required\s*\(/, "flask-security auth_required"}, {/\@http_auth_required\b/, "flask-security http_auth_required"}, {/\@token_auth_required\b/, "flask-security token_auth_required"}, {/\@permission_required\s*\(/, "flask-security/principal permission_required"}, {/\@auth\.login_required/, "flask-httpauth login_required"}, {/\@auth\.verify_password/, "flask-httpauth verify_password"}, {/\@token_auth\.login_required/, "flask-httpauth token_auth"}, {/\@multi_auth\.login_required/, "flask-httpauth multi_auth"}, {/\@protect\s*\(/, "flask-appbuilder protect (a setting can make it public)"}, {/\@has_access\b/, "flask-appbuilder has_access (a setting can make it public)"}, {/\@has_access_api\b/, "flask-appbuilder has_access_api (a setting can make it public)"}, {/\@requires_auth/, "requires_auth"}, {/\@authenticated/, "authenticated"}]