mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 21:28:25 -04:00
Enforce order of permissions decorators
At the moment we mostly have `user_has_permissions` execute first. It shouldn’t matter, but it feels right for us to check that a user is logged in before we check their permissions to a service. Otherwise a malicious user could (maybe) check if a service ID belongs to a real service, and go on to do something malicious with that information. This commit adds some extra test code to enforce that the order is always the same. N.B. decorators in Python execute from closest to furthest (from the line on which the function is defined).
This commit is contained in:
@@ -22,8 +22,8 @@ def agreement():
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/agreement')
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
@login_required
|
||||
def service_agreement(service_id):
|
||||
return render_template(
|
||||
'views/agreement/service-{}.html'.format(current_service.organisation.as_jinja_template),
|
||||
@@ -32,8 +32,8 @@ def service_agreement(service_id):
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/agreement.pdf')
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
@login_required
|
||||
def service_download_agreement(service_id):
|
||||
return send_file(**get_mou(
|
||||
current_service.organisation.crown_status_or_404
|
||||
@@ -41,8 +41,8 @@ def service_download_agreement(service_id):
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/agreement/accept', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
@login_required
|
||||
def service_accept_agreement(service_id):
|
||||
|
||||
if not current_service.organisation:
|
||||
@@ -65,8 +65,8 @@ def service_accept_agreement(service_id):
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/agreement/confirm', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
@login_required
|
||||
def service_confirm_agreement(service_id):
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user