import { ContextPlugin } from "@webiny/handler" ; import { SecurityContext } from "~/types" ; import { TenancyContext } from "@webiny/api-tenancy/types" ; export default ( ) => { return new ContextPlugin < SecurityContext & TenancyContext > ( ( { security , tenancy } ) => { security . addAuthorizer ( async ( ) => { const tenant = tenancy . getCurrentTenant ( ) ; if ( ! tenant ) { return [ ] ; } if ( security . getIdentity ( ) ) { return ; } const group = await security . getStorageOperations ( ) . getGroup ( { where : { tenant : tenant . id , slug : "anonymous" } } ) ; return group ? group . permissions || [ ] : [ ] ; } ) ; } ) ; } ;