@@ -2,6 +2,7 @@ import { Body, Controller, Delete, Get, Param, Post, Put, Query, Req, UseGuards
22import { JwtOrManagementKeyGuard } from '../auth/jwt-or-management-key.guard' ;
33import { ApiBearerAuth , ApiOperation , ApiTags , ApiSecurity } from '@nestjs/swagger' ;
44import { FileSearchService } from './file-search.service' ;
5+ import { MemberVisibilityService } from '../settings/member-visibility.service' ;
56import {
67 FileAccessRulesDto ,
78 FileSearchActivateDto ,
@@ -19,14 +20,30 @@ import {
1920/**
2021 * File Search API (#1385): the setup wizard and the connector's Files tab.
2122 * Every route is scoped to the caller's workspace; setup routes need ADMIN.
23+ *
24+ * Member visibility (settings/member-visibility.service.ts): in a workspace
25+ * set to `restricted`, a member who is not an admin gets 404 (the body an
26+ * unknown id gets) on every route with a connector id they cannot see, before
27+ * the route's own checks. Admins and open workspaces: today's path. The
28+ * route-by-route rules are listed in connectors.member-visibility.spec.ts.
2229 */
2330@ApiTags ( 'File Search' )
2431@ApiBearerAuth ( )
2532@ApiSecurity ( 'api-key' )
2633@UseGuards ( JwtOrManagementKeyGuard )
2734@Controller ( 'api/file-search' )
2835export class FileSearchController {
29- constructor ( private readonly svc : FileSearchService ) { }
36+ constructor (
37+ private readonly svc : FileSearchService ,
38+ private readonly visibility : MemberVisibilityService ,
39+ ) { }
40+
41+ /** 404 for a connector a restricted member cannot see; nothing for admins and open workspaces. */
42+ private async hideUnlessVisible ( req : any , id : string ) : Promise < void > {
43+ const scope = await this . visibility . scopeFor ( req . user ) ;
44+ if ( ! scope . restricted ) return ;
45+ await this . svc . assertVisible ( req . user , id , scope ) ;
46+ }
3047
3148 @Get ( 'capabilities' )
3249 @ApiOperation ( { summary : 'Plan, limits, worker health, protocols and AI availability for the wizard' } )
@@ -59,8 +76,12 @@ export class FileSearchController {
5976 }
6077
6178 @Get ( 'connectors/:id' )
62- @ApiOperation ( { summary : 'Get a File Search connector overview' } )
63- overview ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
79+ @ApiOperation ( {
80+ summary : 'Get a File Search connector overview' ,
81+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
82+ } )
83+ async overview ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
84+ await this . hideUnlessVisible ( req , id ) ;
6485 return this . svc . overview ( req . user , id ) ;
6586 }
6687
@@ -77,8 +98,12 @@ export class FileSearchController {
7798 }
7899
79100 @Get ( 'connectors/:id/scans/:scanId' )
80- @ApiOperation ( { summary : 'Get the status and results of a scan' } )
81- getScan ( @Req ( ) req : any , @Param ( 'id' ) id : string , @Param ( 'scanId' ) scanId : string ) {
101+ @ApiOperation ( {
102+ summary : 'Get the status and results of a scan' ,
103+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
104+ } )
105+ async getScan ( @Req ( ) req : any , @Param ( 'id' ) id : string , @Param ( 'scanId' ) scanId : string ) {
106+ await this . hideUnlessVisible ( req , id ) ;
82107 return this . svc . getScan ( req . user , id , scanId ) ;
83108 }
84109
@@ -107,26 +132,42 @@ export class FileSearchController {
107132 }
108133
109134 @Get ( 'connectors/:id/tree' )
110- @ApiOperation ( { summary : 'Get the folder tree of a connector' } )
111- tree ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
135+ @ApiOperation ( {
136+ summary : 'Get the folder tree of a connector' ,
137+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
138+ } )
139+ async tree ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
140+ await this . hideUnlessVisible ( req , id ) ;
112141 return this . svc . tree ( req . user , id ) ;
113142 }
114143
115144 @Get ( 'connectors/:id/problems' )
116- @ApiOperation ( { summary : 'List indexing problems for a connector' } )
117- problems ( @Req ( ) req : any , @Param ( 'id' ) id : string , @Query ( ) query : PageQueryDto ) {
145+ @ApiOperation ( {
146+ summary : 'List indexing problems for a connector' ,
147+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
148+ } )
149+ async problems ( @Req ( ) req : any , @Param ( 'id' ) id : string , @Query ( ) query : PageQueryDto ) {
150+ await this . hideUnlessVisible ( req , id ) ;
118151 return this . svc . problems ( req . user , id , query ) ;
119152 }
120153
121154 @Get ( 'connectors/:id/runs' )
122- @ApiOperation ( { summary : 'List sync runs for a connector' } )
123- runs ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
155+ @ApiOperation ( {
156+ summary : 'List sync runs for a connector' ,
157+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
158+ } )
159+ async runs ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
160+ await this . hideUnlessVisible ( req , id ) ;
124161 return this . svc . runs ( req . user , id ) ;
125162 }
126163
127164 @Post ( 'connectors/:id/sync' )
128- @ApiOperation ( { summary : 'Trigger an immediate sync' } )
129- syncNow ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
165+ @ApiOperation ( {
166+ summary : 'Trigger an immediate sync' ,
167+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
168+ } )
169+ async syncNow ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
170+ await this . hideUnlessVisible ( req , id ) ;
130171 return this . svc . syncNow ( req . user , id ) ;
131172 }
132173
@@ -155,8 +196,12 @@ export class FileSearchController {
155196 }
156197
157198 @Get ( 'connectors/:id/access-rules' )
158- @ApiOperation ( { summary : 'Get per-connector access rules' } )
159- getRules ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
199+ @ApiOperation ( {
200+ summary : 'Get per-connector access rules' ,
201+ description : 'In a workspace with restricted member visibility, a member who is not an admin gets 404 for a connector they cannot see.' ,
202+ } )
203+ async getRules ( @Req ( ) req : any , @Param ( 'id' ) id : string ) {
204+ await this . hideUnlessVisible ( req , id ) ;
160205 return this . svc . getAccessRules ( req . user , id ) ;
161206 }
162207
0 commit comments