We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Not possible to download files as anonymous user
**Environment**:

  - CTFd Version/Commit: 2.0.0 from master
  - Operating System: Debian Stretch, Ubuntu 18.04, ...
  - Web Browser and Version: Firefox 63

**What happened?**

* In admin, set visibility of challenges to public
* Logout
* Open challenge view (`/challenges`)
* Click on a challenge with a file
* Try to download the file (`/files/c378d661d2c9e103c4409cd4c92d801f/alice_bob.py`
* => Error 403

**What did you expect to happen?**

* ...
* Click on a challenge with a file
* Try to download the file
* File downloads

**How to reproduce your issue**

_see above_

**Any associated stack traces or error logs**

_none_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `CTFd/__init__.py`
Content:
```
1 import sys
2 import os
3 
4 from distutils.version import StrictVersion
5 from flask import Flask
6 from werkzeug.contrib.fixers import ProxyFix
7 from jinja2 import FileSystemLoader
8 from jinja2.sandbox import SandboxedEnvironment
9 from six.moves import input
10 
11 from CTFd import utils
12 from CTFd.utils.migrations import migrations, migrate, upgrade, stamp, create_database
13 from CTFd.utils.sessions import CachingSessionInterface
14 from CTFd.utils.updates import update_check
15 from CTFd.utils.initialization import init_request_processors, init_template_filters, init_template_globals
16 from CTFd.utils.events import socketio
17 from CTFd.plugins import init_plugins
18 
19 # Hack to support Unicode in Python 2 properly
20 if sys.version_info[0] < 3:
21     reload(sys)
22     sys.setdefaultencoding("utf-8")
23 
24 __version__ = '2.0.0'
25 
26 
27 class CTFdFlask(Flask):
28     def __init__(self, *args, **kwargs):
29         """Overriden Jinja constructor setting a custom jinja_environment"""
30         self.jinja_environment = SandboxedBaseEnvironment
31         self.session_interface = CachingSessionInterface(key_prefix='session')
32         Flask.__init__(self, *args, **kwargs)
33 
34     def create_jinja_environment(self):
35         """Overridden jinja environment constructor"""
36         return super(CTFdFlask, self).create_jinja_environment()
37 
38 
39 class SandboxedBaseEnvironment(SandboxedEnvironment):
40     """SandboxEnvironment that mimics the Flask BaseEnvironment"""
41     def __init__(self, app, **options):
42         if 'loader' not in options:
43             options['loader'] = app.create_global_jinja_loader()
44         # Disable cache entirely so that themes can be switched (#662)
45         # If the cache is enabled, switching themes will cause odd rendering errors
46         SandboxedEnvironment.__init__(self, cache_size=0, **options)
47         self.app = app
48 
49 
50 class ThemeLoader(FileSystemLoader):
51     """Custom FileSystemLoader that switches themes based on the configuration value"""
52     def __init__(self, searchpath, encoding='utf-8', followlinks=False):
53         super(ThemeLoader, self).__init__(searchpath, encoding, followlinks)
54         self.overriden_templates = {}
55 
56     def get_source(self, environment, template):
57         # Check if the template has been overriden
58         if template in self.overriden_templates:
59             return self.overriden_templates[template], template, True
60 
61         # Check if the template requested is for the admin panel
62         if template.startswith('admin/'):
63             template = template[6:]  # Strip out admin/
64             template = "/".join(['admin', 'templates', template])
65             return super(ThemeLoader, self).get_source(environment, template)
66 
67         # Load regular theme data
68         theme = utils.get_config('ctf_theme')
69         template = "/".join([theme, 'templates', template])
70         return super(ThemeLoader, self).get_source(environment, template)
71 
72 
73 def confirm_upgrade():
74     if sys.stdin.isatty():
75         print("/*\\ CTFd has updated and must update the database! /*\\")
76         print("/*\\ Please backup your database before proceeding! /*\\")
77         print("/*\\ CTFd maintainers are not responsible for any data loss! /*\\")
78         if input('Run database migrations (Y/N)').lower().strip() == 'y':
79             return True
80         else:
81             print('/*\\ Ignored database migrations... /*\\')
82             return False
83     else:
84         return True
85 
86 
87 def run_upgrade():
88     upgrade()
89     utils.set_config('ctf_version', __version__)
90 
91 
92 def create_app(config='CTFd.config.Config'):
93     app = CTFdFlask(__name__)
94     with app.app_context():
95         app.config.from_object(config)
96 
97         theme_loader = ThemeLoader(os.path.join(app.root_path, 'themes'), followlinks=True)
98         app.jinja_loader = theme_loader
99 
100         from CTFd.models import db, Teams, Solves, Challenges, Fails, Flags, Tags, Files, Tracking
101 
102         url = create_database()
103 
104         # This allows any changes to the SQLALCHEMY_DATABASE_URI to get pushed back in
105         # This is mostly so we can force MySQL's charset
106         app.config['SQLALCHEMY_DATABASE_URI'] = str(url)
107 
108         # Register database
109         db.init_app(app)
110 
111         # Register Flask-Migrate
112         migrations.init_app(app, db)
113 
114         # Alembic sqlite support is lacking so we should just create_all anyway
115         if url.drivername.startswith('sqlite'):
116             db.create_all()
117             stamp()
118         else:
119             # This creates tables instead of db.create_all()
120             # Allows migrations to happen properly
121             upgrade()
122 
123         from CTFd.models import ma
124 
125         ma.init_app(app)
126 
127         app.db = db
128         app.VERSION = __version__
129 
130         from CTFd.cache import cache
131 
132         cache.init_app(app)
133         app.cache = cache
134 
135         # If you have multiple workers you must have a shared cache
136         socketio.init_app(
137             app,
138             async_mode=app.config.get('SOCKETIO_ASYNC_MODE'),
139             message_queue=app.config.get('CACHE_REDIS_URL')
140         )
141 
142         if app.config.get('REVERSE_PROXY'):
143             app.wsgi_app = ProxyFix(app.wsgi_app)
144 
145         version = utils.get_config('ctf_version')
146 
147         # Upgrading from an older version of CTFd
148         if version and (StrictVersion(version) < StrictVersion(__version__)):
149             if confirm_upgrade():
150                 run_upgrade()
151             else:
152                 exit()
153 
154         if not version:
155             utils.set_config('ctf_version', __version__)
156 
157         if not utils.get_config('ctf_theme'):
158             utils.set_config('ctf_theme', 'core')
159 
160         update_check(force=True)
161 
162         init_request_processors(app)
163         init_template_filters(app)
164         init_template_globals(app)
165 
166         # Importing here allows tests to use sensible names (e.g. api instead of api_bp)
167         from CTFd.views import views
168         from CTFd.teams import teams
169         from CTFd.users import users
170         from CTFd.challenges import challenges
171         from CTFd.scoreboard import scoreboard
172         from CTFd.auth import auth
173         from CTFd.admin import admin
174         from CTFd.api import api
175         from CTFd.events import events
176         from CTFd.errors import page_not_found, forbidden, general_error, gateway_error
177 
178         app.register_blueprint(views)
179         app.register_blueprint(teams)
180         app.register_blueprint(users)
181         app.register_blueprint(challenges)
182         app.register_blueprint(scoreboard)
183         app.register_blueprint(auth)
184         app.register_blueprint(api)
185         app.register_blueprint(events)
186 
187         app.register_blueprint(admin)
188 
189         app.register_error_handler(404, page_not_found)
190         app.register_error_handler(403, forbidden)
191         app.register_error_handler(500, general_error)
192         app.register_error_handler(502, gateway_error)
193 
194         init_plugins(app)
195 
196         return app
197
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/CTFd/__init__.py b/CTFd/__init__.py
--- a/CTFd/__init__.py
+++ b/CTFd/__init__.py
@@ -21,7 +21,7 @@
     reload(sys)
     sys.setdefaultencoding("utf-8")
 
-__version__ = '2.0.0'
+__version__ = '2.0.1'
 
 
 class CTFdFlask(Flask):

{"golden_diff": "diff --git a/CTFd/__init__.py b/CTFd/__init__.py\n--- a/CTFd/__init__.py\n+++ b/CTFd/__init__.py\n@@ -21,7 +21,7 @@\n     reload(sys)\n     sys.setdefaultencoding(\"utf-8\")\n \n-__version__ = '2.0.0'\n+__version__ = '2.0.1'\n \n \n class CTFdFlask(Flask):\n", "issue": "Not possible to download files as anonymous user\n**Environment**:\r\n\r\n  - CTFd Version/Commit: 2.0.0 from master\r\n  - Operating System: Debian Stretch, Ubuntu 18.04, ...\r\n  - Web Browser and Version: Firefox 63\r\n\r\n**What happened?**\r\n\r\n* In admin, set visibility of challenges to public\r\n* Logout\r\n* Open challenge view (`/challenges`)\r\n* Click on a challenge with a file\r\n* Try to download the file (`/files/c378d661d2c9e103c4409cd4c92d801f/alice_bob.py`\r\n* => Error 403\r\n\r\n**What did you expect to happen?**\r\n\r\n* ...\r\n* Click on a challenge with a file\r\n* Try to download the file\r\n* File downloads\r\n\r\n**How to reproduce your issue**\r\n\r\n_see above_\r\n\r\n**Any associated stack traces or error logs**\r\n\r\n_none_\n", "before_files": [{"content": "import sys\nimport os\n\nfrom distutils.version import StrictVersion\nfrom flask import Flask\nfrom werkzeug.contrib.fixers import ProxyFix\nfrom jinja2 import FileSystemLoader\nfrom jinja2.sandbox import SandboxedEnvironment\nfrom six.moves import input\n\nfrom CTFd import utils\nfrom CTFd.utils.migrations import migrations, migrate, upgrade, stamp, create_database\nfrom CTFd.utils.sessions import CachingSessionInterface\nfrom CTFd.utils.updates import update_check\nfrom CTFd.utils.initialization import init_request_processors, init_template_filters, init_template_globals\nfrom CTFd.utils.events import socketio\nfrom CTFd.plugins import init_plugins\n\n# Hack to support Unicode in Python 2 properly\nif sys.version_info[0] < 3:\n    reload(sys)\n    sys.setdefaultencoding(\"utf-8\")\n\n__version__ = '2.0.0'\n\n\nclass CTFdFlask(Flask):\n    def __init__(self, *args, **kwargs):\n        \"\"\"Overriden Jinja constructor setting a custom jinja_environment\"\"\"\n        self.jinja_environment = SandboxedBaseEnvironment\n        self.session_interface = CachingSessionInterface(key_prefix='session')\n        Flask.__init__(self, *args, **kwargs)\n\n    def create_jinja_environment(self):\n        \"\"\"Overridden jinja environment constructor\"\"\"\n        return super(CTFdFlask, self).create_jinja_environment()\n\n\nclass SandboxedBaseEnvironment(SandboxedEnvironment):\n    \"\"\"SandboxEnvironment that mimics the Flask BaseEnvironment\"\"\"\n    def __init__(self, app, **options):\n        if 'loader' not in options:\n            options['loader'] = app.create_global_jinja_loader()\n        # Disable cache entirely so that themes can be switched (#662)\n        # If the cache is enabled, switching themes will cause odd rendering errors\n        SandboxedEnvironment.__init__(self, cache_size=0, **options)\n        self.app = app\n\n\nclass ThemeLoader(FileSystemLoader):\n    \"\"\"Custom FileSystemLoader that switches themes based on the configuration value\"\"\"\n    def __init__(self, searchpath, encoding='utf-8', followlinks=False):\n        super(ThemeLoader, self).__init__(searchpath, encoding, followlinks)\n        self.overriden_templates = {}\n\n    def get_source(self, environment, template):\n        # Check if the template has been overriden\n        if template in self.overriden_templates:\n            return self.overriden_templates[template], template, True\n\n        # Check if the template requested is for the admin panel\n        if template.startswith('admin/'):\n            template = template[6:]  # Strip out admin/\n            template = \"/\".join(['admin', 'templates', template])\n            return super(ThemeLoader, self).get_source(environment, template)\n\n        # Load regular theme data\n        theme = utils.get_config('ctf_theme')\n        template = \"/\".join([theme, 'templates', template])\n        return super(ThemeLoader, self).get_source(environment, template)\n\n\ndef confirm_upgrade():\n    if sys.stdin.isatty():\n        print(\"/*\\\\ CTFd has updated and must update the database! /*\\\\\")\n        print(\"/*\\\\ Please backup your database before proceeding! /*\\\\\")\n        print(\"/*\\\\ CTFd maintainers are not responsible for any data loss! /*\\\\\")\n        if input('Run database migrations (Y/N)').lower().strip() == 'y':\n            return True\n        else:\n            print('/*\\\\ Ignored database migrations... /*\\\\')\n            return False\n    else:\n        return True\n\n\ndef run_upgrade():\n    upgrade()\n    utils.set_config('ctf_version', __version__)\n\n\ndef create_app(config='CTFd.config.Config'):\n    app = CTFdFlask(__name__)\n    with app.app_context():\n        app.config.from_object(config)\n\n        theme_loader = ThemeLoader(os.path.join(app.root_path, 'themes'), followlinks=True)\n        app.jinja_loader = theme_loader\n\n        from CTFd.models import db, Teams, Solves, Challenges, Fails, Flags, Tags, Files, Tracking\n\n        url = create_database()\n\n        # This allows any changes to the SQLALCHEMY_DATABASE_URI to get pushed back in\n        # This is mostly so we can force MySQL's charset\n        app.config['SQLALCHEMY_DATABASE_URI'] = str(url)\n\n        # Register database\n        db.init_app(app)\n\n        # Register Flask-Migrate\n        migrations.init_app(app, db)\n\n        # Alembic sqlite support is lacking so we should just create_all anyway\n        if url.drivername.startswith('sqlite'):\n            db.create_all()\n            stamp()\n        else:\n            # This creates tables instead of db.create_all()\n            # Allows migrations to happen properly\n            upgrade()\n\n        from CTFd.models import ma\n\n        ma.init_app(app)\n\n        app.db = db\n        app.VERSION = __version__\n\n        from CTFd.cache import cache\n\n        cache.init_app(app)\n        app.cache = cache\n\n        # If you have multiple workers you must have a shared cache\n        socketio.init_app(\n            app,\n            async_mode=app.config.get('SOCKETIO_ASYNC_MODE'),\n            message_queue=app.config.get('CACHE_REDIS_URL')\n        )\n\n        if app.config.get('REVERSE_PROXY'):\n            app.wsgi_app = ProxyFix(app.wsgi_app)\n\n        version = utils.get_config('ctf_version')\n\n        # Upgrading from an older version of CTFd\n        if version and (StrictVersion(version) < StrictVersion(__version__)):\n            if confirm_upgrade():\n                run_upgrade()\n            else:\n                exit()\n\n        if not version:\n            utils.set_config('ctf_version', __version__)\n\n        if not utils.get_config('ctf_theme'):\n            utils.set_config('ctf_theme', 'core')\n\n        update_check(force=True)\n\n        init_request_processors(app)\n        init_template_filters(app)\n        init_template_globals(app)\n\n        # Importing here allows tests to use sensible names (e.g. api instead of api_bp)\n        from CTFd.views import views\n        from CTFd.teams import teams\n        from CTFd.users import users\n        from CTFd.challenges import challenges\n        from CTFd.scoreboard import scoreboard\n        from CTFd.auth import auth\n        from CTFd.admin import admin\n        from CTFd.api import api\n        from CTFd.events import events\n        from CTFd.errors import page_not_found, forbidden, general_error, gateway_error\n\n        app.register_blueprint(views)\n        app.register_blueprint(teams)\n        app.register_blueprint(users)\n        app.register_blueprint(challenges)\n        app.register_blueprint(scoreboard)\n        app.register_blueprint(auth)\n        app.register_blueprint(api)\n        app.register_blueprint(events)\n\n        app.register_blueprint(admin)\n\n        app.register_error_handler(404, page_not_found)\n        app.register_error_handler(403, forbidden)\n        app.register_error_handler(500, general_error)\n        app.register_error_handler(502, gateway_error)\n\n        init_plugins(app)\n\n        return app\n", "path": "CTFd/__init__.py"}], "after_files": [{"content": "import sys\nimport os\n\nfrom distutils.version import StrictVersion\nfrom flask import Flask\nfrom werkzeug.contrib.fixers import ProxyFix\nfrom jinja2 import FileSystemLoader\nfrom jinja2.sandbox import SandboxedEnvironment\nfrom six.moves import input\n\nfrom CTFd import utils\nfrom CTFd.utils.migrations import migrations, migrate, upgrade, stamp, create_database\nfrom CTFd.utils.sessions import CachingSessionInterface\nfrom CTFd.utils.updates import update_check\nfrom CTFd.utils.initialization import init_request_processors, init_template_filters, init_template_globals\nfrom CTFd.utils.events import socketio\nfrom CTFd.plugins import init_plugins\n\n# Hack to support Unicode in Python 2 properly\nif sys.version_info[0] < 3:\n    reload(sys)\n    sys.setdefaultencoding(\"utf-8\")\n\n__version__ = '2.0.1'\n\n\nclass CTFdFlask(Flask):\n    def __init__(self, *args, **kwargs):\n        \"\"\"Overriden Jinja constructor setting a custom jinja_environment\"\"\"\n        self.jinja_environment = SandboxedBaseEnvironment\n        self.session_interface = CachingSessionInterface(key_prefix='session')\n        Flask.__init__(self, *args, **kwargs)\n\n    def create_jinja_environment(self):\n        \"\"\"Overridden jinja environment constructor\"\"\"\n        return super(CTFdFlask, self).create_jinja_environment()\n\n\nclass SandboxedBaseEnvironment(SandboxedEnvironment):\n    \"\"\"SandboxEnvironment that mimics the Flask BaseEnvironment\"\"\"\n    def __init__(self, app, **options):\n        if 'loader' not in options:\n            options['loader'] = app.create_global_jinja_loader()\n        # Disable cache entirely so that themes can be switched (#662)\n        # If the cache is enabled, switching themes will cause odd rendering errors\n        SandboxedEnvironment.__init__(self, cache_size=0, **options)\n        self.app = app\n\n\nclass ThemeLoader(FileSystemLoader):\n    \"\"\"Custom FileSystemLoader that switches themes based on the configuration value\"\"\"\n    def __init__(self, searchpath, encoding='utf-8', followlinks=False):\n        super(ThemeLoader, self).__init__(searchpath, encoding, followlinks)\n        self.overriden_templates = {}\n\n    def get_source(self, environment, template):\n        # Check if the template has been overriden\n        if template in self.overriden_templates:\n            return self.overriden_templates[template], template, True\n\n        # Check if the template requested is for the admin panel\n        if template.startswith('admin/'):\n            template = template[6:]  # Strip out admin/\n            template = \"/\".join(['admin', 'templates', template])\n            return super(ThemeLoader, self).get_source(environment, template)\n\n        # Load regular theme data\n        theme = utils.get_config('ctf_theme')\n        template = \"/\".join([theme, 'templates', template])\n        return super(ThemeLoader, self).get_source(environment, template)\n\n\ndef confirm_upgrade():\n    if sys.stdin.isatty():\n        print(\"/*\\\\ CTFd has updated and must update the database! /*\\\\\")\n        print(\"/*\\\\ Please backup your database before proceeding! /*\\\\\")\n        print(\"/*\\\\ CTFd maintainers are not responsible for any data loss! /*\\\\\")\n        if input('Run database migrations (Y/N)').lower().strip() == 'y':\n            return True\n        else:\n            print('/*\\\\ Ignored database migrations... /*\\\\')\n            return False\n    else:\n        return True\n\n\ndef run_upgrade():\n    upgrade()\n    utils.set_config('ctf_version', __version__)\n\n\ndef create_app(config='CTFd.config.Config'):\n    app = CTFdFlask(__name__)\n    with app.app_context():\n        app.config.from_object(config)\n\n        theme_loader = ThemeLoader(os.path.join(app.root_path, 'themes'), followlinks=True)\n        app.jinja_loader = theme_loader\n\n        from CTFd.models import db, Teams, Solves, Challenges, Fails, Flags, Tags, Files, Tracking\n\n        url = create_database()\n\n        # This allows any changes to the SQLALCHEMY_DATABASE_URI to get pushed back in\n        # This is mostly so we can force MySQL's charset\n        app.config['SQLALCHEMY_DATABASE_URI'] = str(url)\n\n        # Register database\n        db.init_app(app)\n\n        # Register Flask-Migrate\n        migrations.init_app(app, db)\n\n        # Alembic sqlite support is lacking so we should just create_all anyway\n        if url.drivername.startswith('sqlite'):\n            db.create_all()\n            stamp()\n        else:\n            # This creates tables instead of db.create_all()\n            # Allows migrations to happen properly\n            upgrade()\n\n        from CTFd.models import ma\n\n        ma.init_app(app)\n\n        app.db = db\n        app.VERSION = __version__\n\n        from CTFd.cache import cache\n\n        cache.init_app(app)\n        app.cache = cache\n\n        # If you have multiple workers you must have a shared cache\n        socketio.init_app(\n            app,\n            async_mode=app.config.get('SOCKETIO_ASYNC_MODE'),\n            message_queue=app.config.get('CACHE_REDIS_URL')\n        )\n\n        if app.config.get('REVERSE_PROXY'):\n            app.wsgi_app = ProxyFix(app.wsgi_app)\n\n        version = utils.get_config('ctf_version')\n\n        # Upgrading from an older version of CTFd\n        if version and (StrictVersion(version) < StrictVersion(__version__)):\n            if confirm_upgrade():\n                run_upgrade()\n            else:\n                exit()\n\n        if not version:\n            utils.set_config('ctf_version', __version__)\n\n        if not utils.get_config('ctf_theme'):\n            utils.set_config('ctf_theme', 'core')\n\n        update_check(force=True)\n\n        init_request_processors(app)\n        init_template_filters(app)\n        init_template_globals(app)\n\n        # Importing here allows tests to use sensible names (e.g. api instead of api_bp)\n        from CTFd.views import views\n        from CTFd.teams import teams\n        from CTFd.users import users\n        from CTFd.challenges import challenges\n        from CTFd.scoreboard import scoreboard\n        from CTFd.auth import auth\n        from CTFd.admin import admin\n        from CTFd.api import api\n        from CTFd.events import events\n        from CTFd.errors import page_not_found, forbidden, general_error, gateway_error\n\n        app.register_blueprint(views)\n        app.register_blueprint(teams)\n        app.register_blueprint(users)\n        app.register_blueprint(challenges)\n        app.register_blueprint(scoreboard)\n        app.register_blueprint(auth)\n        app.register_blueprint(api)\n        app.register_blueprint(events)\n\n        app.register_blueprint(admin)\n\n        app.register_error_handler(404, page_not_found)\n        app.register_error_handler(403, forbidden)\n        app.register_error_handler(500, general_error)\n        app.register_error_handler(502, gateway_error)\n\n        init_plugins(app)\n\n        return app\n", "path": "CTFd/__init__.py"}]}