Skip to content

Commit 839d41b

Browse files
author
Javier Barbero
committed
Protect access to PlotViewer routes
1 parent c55b48f commit 839d41b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

signac_dashboard/modules/plot_viewer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This software is licensed under the BSD 3-Clause License.
44
from typing import Callable, Dict, Iterable, List, Tuple, Union
55

6+
import flask_login
67
from flask import abort, render_template
78
from jinja2.exceptions import TemplateNotFound
89
from signac import Project
@@ -12,13 +13,6 @@
1213
from signac_dashboard.module import Module
1314

1415

15-
def plot_viewer_asset(filename):
16-
try:
17-
return render_template(f"plot_viewer/{filename}")
18-
except TemplateNotFound:
19-
abort(404, "The file requested does not exist.")
20-
21-
2216
class PlotViewer(Module):
2317
"""Displays a plot associated with the job.
2418
@@ -96,7 +90,13 @@ def get_cards(self, job_or_project):
9690

9791
def register(self, dashboard: Dashboard):
9892
# Register routes
99-
dashboard.app.route("/module/plot_viewer/<path:filename>")(plot_viewer_asset)
93+
@dashboard.app.route("/module/plot_viewer/<path:filename>")
94+
@flask_login.login_required
95+
def plot_viewer_asset(filename):
96+
try:
97+
return render_template(f"plot_viewer/{filename}")
98+
except TemplateNotFound:
99+
abort(404, "The file requested does not exist.")
100100

101101
# Register assets
102102
assets = ["js/plot_viewer.js"]

0 commit comments

Comments
 (0)