@@ -6,11 +6,14 @@ import {
66 assertEqual ,
77 OpenOpsId ,
88 Organization ,
9+ Permission ,
910 PrincipalType ,
1011 SERVICE_KEY_SECURITY_OPENAPI ,
1112 UpdateOrganizationRequestBody ,
1213} from '@openops/shared' ;
1314import { StatusCodes } from 'http-status-codes' ;
15+ import { organizationIdResolver } from '../core/security/route-policies/property-source-factory' ;
16+ import { getOrganizationScopedRoutePolicy } from '../core/security/route-policies/route-security-policy-factory' ;
1417import { organizationService } from './organization.service' ;
1518
1619export const organizationController : FastifyPluginAsyncTypebox = async (
@@ -37,6 +40,14 @@ export const organizationController: FastifyPluginAsyncTypebox = async (
3740} ;
3841
3942const UpdateOrganizationRequest = {
43+ config : {
44+ allowedPrincipals : [ PrincipalType . USER ] ,
45+ security : getOrganizationScopedRoutePolicy ( {
46+ allowedPrincipals : [ PrincipalType . USER ] ,
47+ permission : Permission . WRITE_ORGANIZATION ,
48+ organizationIdSource : organizationIdResolver . fromParams ( 'id' ) ,
49+ } ) ,
50+ } ,
4051 schema : {
4152 body : UpdateOrganizationRequestBody ,
4253 params : Type . Object ( {
@@ -53,6 +64,10 @@ const UpdateOrganizationRequest = {
5364const GetOrganizationRequest = {
5465 config : {
5566 allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
67+ security : getOrganizationScopedRoutePolicy ( {
68+ allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
69+ organizationIdSource : organizationIdResolver . fromParams ( 'id' ) ,
70+ } ) ,
5671 } ,
5772 schema : {
5873 tags : [ 'organizations' ] ,
0 commit comments