Skip to content

Commit

Permalink
Merge pull request moinwiki#1751 from UlrichB22/admin_permission
Browse files Browse the repository at this point in the history
Restrict all admin views to the superuser
  • Loading branch information
RogerHaase authored Sep 5, 2024
2 parents e342611 + d1a30cf commit 5e46430
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/moin/apps/admin/_tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright: 2011 Sam Toyer
# Copyright: 2024 MoinMoin:UlrichB
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details

"""
Expand All @@ -18,9 +19,9 @@
({"endpoint": "admin.userprofile", "user_name": "DoesntExist"}, "403 FORBIDDEN", ("<html>", "</html>")),
({"endpoint": "admin.wikiconfig"}, "403 FORBIDDEN", ("<html>", "</html>")),
({"endpoint": "admin.wikiconfighelp"}, "403 FORBIDDEN", ("<html>", "</html>")),
({"endpoint": "admin.interwikihelp"}, "200 OK", ("<html>", "</html>")),
({"endpoint": "admin.highlighterhelp"}, "200 OK", ("<html>", "</html>")),
({"endpoint": "admin.itemsize"}, "200 OK", ("<html>", "</html>")),
({"endpoint": "admin.interwikihelp"}, "403 FORBIDDEN", ("<html>", "</html>")),
({"endpoint": "admin.highlighterhelp"}, "403 FORBIDDEN", ("<html>", "</html>")),
({"endpoint": "admin.itemsize"}, "403 FORBIDDEN", ("<html>", "</html>")),
),
)
def test_admin(app, url_for_args, status, data):
Expand Down
4 changes: 4 additions & 0 deletions src/moin/apps/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def index():


@admin.route("/user")
@require_permission(SUPERUSER)
def index_user():
return render_template(
"user/index_user.html",
Expand Down Expand Up @@ -359,6 +360,7 @@ def format_default(default):


@admin.route("/highlighterhelp", methods=["GET"])
@require_permission(SUPERUSER)
def highlighterhelp():
"""display a table with list of available Pygments lexers"""
import pygments.lexers
Expand All @@ -375,6 +377,7 @@ def highlighterhelp():


@admin.route("/interwikihelp", methods=["GET"])
@require_permission(SUPERUSER)
def interwikihelp():
"""display a table with list of known interwiki names / urls"""
headings = [_("InterWiki name"), _("URL")]
Expand All @@ -383,6 +386,7 @@ def interwikihelp():


@admin.route("/itemsize", methods=["GET"])
@require_permission(SUPERUSER)
def itemsize():
"""display a table with item sizes"""
headings = [_("Size"), _("Item name")]
Expand Down

0 comments on commit 5e46430

Please sign in to comment.