@@ -2,9 +2,10 @@ import {
22 FastifyPluginAsyncTypebox ,
33 Type ,
44} from '@fastify/type-provider-typebox' ;
5- import { OpenOpsId , PrincipalType } from '@openops/shared' ;
5+ import { OpenOpsId , Permission , PrincipalType } from '@openops/shared' ;
66import { FastifyRequest } from 'fastify' ;
77import { entitiesMustBeOwnedByCurrentProject } from '../authentication/authorization' ;
8+ import { getProjectScopedRoutePolicy } from '../core/security/route-policies/route-security-policy-factory' ;
89import { flowTemplateService } from './flow-template.service' ;
910
1011export const flowTemplateController : FastifyPluginAsyncTypebox = async (
@@ -17,6 +18,10 @@ export const flowTemplateController: FastifyPluginAsyncTypebox = async (
1718 {
1819 config : {
1920 allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
21+ security : getProjectScopedRoutePolicy ( {
22+ allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
23+ permission : Permission . READ_TEMPLATE ,
24+ } ) ,
2025 } ,
2126 schema : {
2227 tags : [ 'flow-templates' ] ,
@@ -53,6 +58,10 @@ export const flowTemplateController: FastifyPluginAsyncTypebox = async (
5358 {
5459 config : {
5560 allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
61+ security : getProjectScopedRoutePolicy ( {
62+ allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
63+ permission : Permission . READ_TEMPLATE ,
64+ } ) ,
5665 } ,
5766 schema : {
5867 tags : [ 'flow-templates' ] ,
@@ -73,6 +82,10 @@ export const flowTemplateController: FastifyPluginAsyncTypebox = async (
7382 {
7483 config : {
7584 allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
85+ security : getProjectScopedRoutePolicy ( {
86+ allowedPrincipals : [ PrincipalType . USER , PrincipalType . SERVICE ] ,
87+ permission : Permission . WRITE_TEMPLATE ,
88+ } ) ,
7689 } ,
7790 schema : {
7891 body : {
0 commit comments