22using Microsoft . AspNetCore . Authorization ;
33using Microsoft . AspNetCore . Mvc ;
44using XtremeIdiots . Portal . Integrations . Servers . Api . Client . V1 ;
5+ using XtremeIdiots . Portal . Repository . Api . Client . V1 ;
56using XtremeIdiots . Portal . Web . Auth . Constants ;
67
78namespace XtremeIdiots . Portal . Web . ApiControllers ;
89
9- [ Authorize ( Policy = AuthPolicies . GameServers_Credentials_Ftp_Write ) ]
10+ [ Authorize ]
1011[ Route ( "api/ftp" ) ]
1112public class FtpBrowseApiController (
13+ IAuthorizationService authorizationService ,
14+ IRepositoryApiClient repositoryApiClient ,
1215 IServersApiClient serversApiClient ,
1316 TelemetryClient telemetryClient ,
1417 ILogger < FtpBrowseApiController > logger ,
@@ -19,6 +22,15 @@ public async Task<IActionResult> Browse(Guid gameServerId, [FromQuery] string? p
1922 {
2023 return await ExecuteWithErrorHandlingAsync ( async ( ) =>
2124 {
25+ var gameServerResponse = await repositoryApiClient . GameServers . V1 . GetGameServer ( gameServerId ) . ConfigureAwait ( false ) ;
26+ if ( ! gameServerResponse . IsSuccess || gameServerResponse . Result ? . Data is null )
27+ return Forbid ( ) ;
28+
29+ var gameServer = gameServerResponse . Result . Data ;
30+ var authResult = await authorizationService . AuthorizeAsync ( User , gameServer . GameType , AuthPolicies . GameServers_Credentials_Ftp_Write ) . ConfigureAwait ( false ) ;
31+ if ( ! authResult . Succeeded )
32+ return Forbid ( ) ;
33+
2234 var result = await serversApiClient . FtpBrowse . V1 . BrowseDirectory ( gameServerId , path ) . ConfigureAwait ( false ) ;
2335
2436 if ( ! result . IsSuccess || result . Result ? . Data == null )
0 commit comments