Skip to content

Commit

Permalink
fix: auth functions for views do not work
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Nov 11, 2024
1 parent 1acf62c commit 8f94d4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions ckanext/check_link/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from flask import Blueprint

import ckan.plugins.toolkit as tk
from ckan import authz, model
from ckan import model
from ckan.logic import parse_params

from ckanext.collection import shared

from ckanext.check_link.model import Report

if TYPE_CHECKING:
from ckan.types import Context
Expand All @@ -34,11 +33,13 @@

@bp.route("/organization/<organization_id>/check-link/report")
def organization_report(organization_id: str):
if not authz.is_authorized_boolean(
"check_link_view_report_page",
{"user": tk.g.user},
{"organization_id": organization_id},
):
try:
tk.check_access(
"check_link_view_report_page",
{"user": tk.g.user},
{"organization_id": organization_id},
)
except tk.NotAuthorized:
return tk.abort(403)

try:
Expand Down Expand Up @@ -68,9 +69,13 @@ def organization_report(organization_id: str):

@bp.route("/dataset/<package_id>/check-link/report")
def package_report(package_id: str):
if not authz.is_authorized_boolean(
"check_link_view_report_page", {"user": tk.g.user}, {"package_id": package_id}
):
try:
tk.check_access(
"check_link_view_report_page",
{"user": tk.g.user},
{"package_id": package_id},
)
except tk.NotAuthorized:
return tk.abort(403)

try:
Expand Down Expand Up @@ -99,9 +104,13 @@ def report(
organization_id: str | None = None,
package_id: str | None = None,
):
if not authz.is_authorized_boolean(
"check_link_view_report_page", {"user": tk.g.user}, {}
):
try:
tk.check_access(
"check_link_view_report_page",
{"user": tk.g.user},
{},
)
except tk.NotAuthorized:
return tk.abort(403)

col_name = "check-link-report"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ckanext-check-link"
version = "0.2.2.a0"
version = "0.2.2"
description = "Resource URL checker"
classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",]
keywords = [ "CKAN",]
Expand Down

0 comments on commit 8f94d4e

Please sign in to comment.