Skip to content

Commit

Permalink
feat(views): check resource owner;
Browse files Browse the repository at this point in the history
- Confirm that the resource id belongs to the package id.
  • Loading branch information
JVickery-TBS committed Nov 16, 2023
1 parent 46bc35a commit 2defc6a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ckanext/xloader/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from flask import Blueprint

from ckanapi import LocalCKAN
from ckan.plugins.toolkit import _, h, g, render, request, abort, NotAuthorized, get_action
from ckan.plugins.toolkit import _, h, g, render, request, abort, NotAuthorized, get_action, ObjectNotFound

import ckanext.xloader.utils as utils

Expand All @@ -23,6 +22,13 @@ def delete_datastore_table(id, resource_id):
if u'cancel' in request.form:
return h.redirect_to(u'xloader.resource_data', id=id, resource_id=resource_id)

try:
res_dict = get_action('resource_show')(context, {"id": resource_id})
if res_dict.get('package_id') != id:
raise ObjectNotFound
except ObjectNotFound:
return abort(404, _(u'Resource not found'))

if request.method == 'POST':
context = {"user": g.user}

Expand Down

0 comments on commit 2defc6a

Please sign in to comment.