Tighten API access checks by website section and share permissions

This commit is contained in:
Mike Cao committed 2026-06-02 15:29:23 -07:00
1 parent 8bc49a29e3
commit ade0819be1
69 files changed
+303 -188

No files matched your search

@@ -1,6 +1,6 @@
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataById } from '@/queries/sql/events/getEventDataById';
export async function GET(
@@ -15,7 +15,7 @@ export async function GET(
const { websiteId, eventId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataFields } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataProperties } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, pagingParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventData } from '@/queries/sql/events/getEventData';
export async function GET(
@@ -24,7 +24,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -47,4 +47,4 @@ export async function GET(
}
return json({ data: [...eventMap.values()], count, page, pageSize });
}
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataStats } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getEventDataValues } from '@/queries/sql';
export async function GET(
@@ -26,7 +26,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
return unauthorized();
}