π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
fix: authorize the super admin guard against the calling organization
Enno Gelhaus246c3c03965b
diff --git a/apps/backend/src/services/auth/public.auth.middleware.ts b/apps/backend/src/services/auth/public.auth.middleware.tsindex b02365ba5..96f2b11de 100644--- a/apps/backend/src/services/auth/public.auth.middleware.ts+++ b/apps/backend/src/services/auth/public.auth.middleware.ts@@ -62,6 +62,8 @@ export class PublicAuthMiddleware implements NestMiddleware {}this.setOrg(req, org);+ // @ts-ignore+ req.authOrgId = org.id;const overrideOrgId = (req.headers['x-postiz-org'] as string)?.trim();diff --git a/apps/backend/src/services/auth/super.admin.guard.ts b/apps/backend/src/services/auth/super.admin.guard.tsindex ded50f99d..b52e5c44a 100644--- a/apps/backend/src/services/auth/super.admin.guard.ts+++ b/apps/backend/src/services/auth/super.admin.guard.ts@@ -16,13 +16,19 @@ export class SuperAdminGuard implements CanActivate {const request: Request = context.switchToHttp().getRequest();// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-expect-error- const { org, isOAuthApp }: { org: Organization; isOAuthApp?: boolean } =+ const {+ org,+ isOAuthApp,+ authOrgId,+ }: { org: Organization; isOAuthApp?: boolean; authOrgId?: string } =request;+ const orgId = authOrgId || org?.id;+if (- !org ||+ !orgId ||isOAuthApp ||- !(await this._organizationService.canUseSuperAdminApi(org.id))+ !(await this._organizationService.canUseSuperAdminApi(orgId))) {throw new HttpException({ msg: 'Unauthorized' }, 403);}