@@ -32,7 +32,7 @@ func postTransfers(c *gin.Context) {
3232 if len (auth ) != 2 || auth [0 ] != "Bearer" {
3333 c .Header ("WWW-Authenticate" , "Bearer" )
3434 c .AbortWithStatusJSON (http .StatusUnauthorized , gin.H {
35- "error" : "The required authorization heads were not present in the request." ,
35+ "error" : "The required authorization headers were not present in the request." ,
3636 })
3737 return
3838 }
@@ -43,6 +43,11 @@ func postTransfers(c *gin.Context) {
4343 return
4444 }
4545
46+ if ! token .HasScope (tokens .ServerTransfer ) {
47+ c .AbortWithStatusJSON (http .StatusForbidden , gin.H {"error" : "Forbidden." })
48+ return
49+ }
50+
4651 manager := middleware .ExtractManager (c )
4752 u , err := uuid .Parse (token .Subject )
4853 if err != nil {
@@ -142,14 +147,13 @@ func postTransfers(c *gin.Context) {
142147 return
143148 }
144149
145-
146150 // Used to read the file and checksum from the request body.
147151 mr := multipart .NewReader (c .Request .Body , params ["boundary" ])
148152
149153 var (
150- hasArchive bool
151- archiveChecksum string
152- archiveChecksumReceived string
154+ hasArchive bool
155+ archiveChecksum string
156+ archiveChecksumReceived string
153157 backupChecksumsCalculated = make (map [string ]string )
154158 backupChecksumsReceived = make (map [string ]string )
155159 )
208212
209213 case name == "install_logs" :
210214 trnsfr .Log ().Debug ("received install logs" )
211-
215+
212216 // Create install log directory if it doesn't exist
213217 cfg := config .Get ()
214218 installLogDir := filepath .Join (cfg .System .LogDirectory , "install" )
@@ -217,33 +221,33 @@ out:
217221 trnsfr .Log ().WithError (err ).Warn ("failed to create install log directory, skipping" )
218222 break
219223 }
220-
224+
221225 // Use the correct install log path with server UUID
222226 installLogPath := filepath .Join (installLogDir , trnsfr .Server .ID ()+ ".log" )
223-
227+
224228 // Create the install log file
225229 installLogFile , err := os .Create (installLogPath )
226230 if err != nil {
227231 // Don't fail transfer for install logs, just log and continue
228232 trnsfr .Log ().WithError (err ).Warn ("failed to create install log file, skipping" )
229233 break
230234 }
231-
235+
232236 // Stream the install logs to file
233237 if _ , err := io .Copy (installLogFile , p ); err != nil {
234238 installLogFile .Close ()
235239 // Don't fail transfer for install logs, just log and continue
236240 trnsfr .Log ().WithError (err ).Warn ("failed to stream install logs to file, skipping" )
237241 break
238242 }
239-
243+
240244 if err := installLogFile .Close (); err != nil {
241245 // Don't fail transfer for install logs, just log and continue
242246 trnsfr .Log ().WithError (err ).Warn ("failed to close install log file" )
243247 }
244-
248+
245249 trnsfr .Log ().WithField ("path" , installLogPath ).Debug ("install logs saved successfully" )
246-
250+
247251 case strings .HasPrefix (name , "backup_" ):
248252 backupName := strings .TrimPrefix (name , "backup_" )
249253 trnsfr .Log ().WithField ("backup" , backupName ).Debug ("received backup file" )
0 commit comments