diff --git a/CTFd/admin.py b/CTFd/admin.py index 64df626d..f6b480c4 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -49,6 +49,7 @@ def admin_config(): try: view_challenges_unregistered = bool(request.form.get('view_challenges_unregistered', None)) + view_scoreboard_if_authed = bool(request.form.get('view_scoreboard_if_authed', None)) prevent_registration = bool(request.form.get('prevent_registration', None)) prevent_name_change = bool(request.form.get('prevent_name_change', None)) view_after_ctf = bool(request.form.get('view_after_ctf', None)) @@ -57,6 +58,7 @@ def admin_config(): mail_ssl = bool(request.form.get('mail_ssl', None)) except (ValueError, TypeError): view_challenges_unregistered = None + view_scoreboard_if_authed = None prevent_registration = None prevent_name_change = None view_after_ctf = None @@ -65,6 +67,7 @@ def admin_config(): mail_ssl = None finally: view_challenges_unregistered = set_config('view_challenges_unregistered', view_challenges_unregistered) + view_scoreboard_if_authed = set_config('view_scoreboard_if_authed', view_scoreboard_if_authed) prevent_registration = set_config('prevent_registration', prevent_registration) prevent_name_change = set_config('prevent_name_change', prevent_name_change) view_after_ctf = set_config('view_after_ctf', view_after_ctf) @@ -119,6 +122,7 @@ def admin_config(): mail_ssl = get_config('mail_ssl') view_challenges_unregistered = get_config('view_challenges_unregistered') + view_scoreboard_if_authed = get_config('view_scoreboard_if_authed') prevent_registration = get_config('prevent_registration') prevent_name_change = get_config('prevent_name_change') verify_emails = get_config('verify_emails') @@ -155,6 +159,7 @@ def admin_config(): mail_tls=mail_tls, mail_ssl=mail_ssl, view_challenges_unregistered=view_challenges_unregistered, + view_scoreboard_if_authed=view_scoreboard_if_authed, prevent_registration=prevent_registration, mg_base_url=mg_base_url, mg_api_key=mg_api_key, diff --git a/CTFd/scoreboard.py b/CTFd/scoreboard.py index 5b68afc1..121acd47 100644 --- a/CTFd/scoreboard.py +++ b/CTFd/scoreboard.py @@ -1,5 +1,5 @@ -from flask import current_app as app, session, render_template, jsonify, Blueprint -from CTFd.utils import unix_time +from flask import current_app as app, session, render_template, jsonify, Blueprint, redirect, url_for, request +from CTFd.utils import unix_time, authed, get_config from CTFd.models import db, Teams, Solves, Challenges scoreboard = Blueprint('scoreboard', __name__) @@ -7,6 +7,8 @@ scoreboard = Blueprint('scoreboard', __name__) @scoreboard.route('/scoreboard') def scoreboard_view(): + if get_config('view_scoreboard_if_authed') and not authed(): + return redirect(url_for('auth.login', next=request.path)) score = db.func.sum(Challenges.value).label('score') quickest = db.func.max(Solves.date).label('quickest') teams = db.session.query(Solves.teamid, Teams.name, score)\ @@ -20,6 +22,8 @@ def scoreboard_view(): @scoreboard.route('/scores') def scores(): + if get_config('view_scoreboard_if_authed') and not authed(): + return redirect(url_for('auth.login', next=request.path)) score = db.func.sum(Challenges.value).label('score') quickest = db.func.max(Solves.date).label('quickest') teams = db.session.query(Solves.teamid, Teams.name, score)\ @@ -36,6 +40,8 @@ def scores(): @scoreboard.route('/top/') def topteams(count): + if get_config('view_scoreboard_if_authed') and not authed(): + return redirect(url_for('auth.login', next=request.path)) try: count = int(count) except: diff --git a/CTFd/templates/admin/config.html b/CTFd/templates/admin/config.html index 9c28c020..3ee0cc52 100644 --- a/CTFd/templates/admin/config.html +++ b/CTFd/templates/admin/config.html @@ -110,6 +110,7 @@
  • End Time
  • + * All time fields required
    @@ -163,9 +164,12 @@ {% endfor %}
    - + + + {% if start is defined and start != None %}value="{{ start }}"{% endif %} readonly> +
    @@ -219,9 +223,12 @@ {% endfor %}
    - + + + {% if end is defined and end != None %}value="{{ end }}"{% endif %} readonly> + @@ -247,6 +254,14 @@ +
    + +
    +