meateam / api-gateway

api gateway
Apache License 2.0
10 stars 4 forks source link

BUG: download file with Dropbox auth-type returns 401 statusCode although it also returns the file #207

Open ItayMarder opened 4 years ago

ItayMarder commented 4 years ago

const options = { method: 'get', url: http://drive-rabaz.northeurope.cloudapp.azure.com/api/files/${fileId}?alt=media, headers: { 'Auth-Type: Service', 'Auth-User: s0000001', 'Authorization: Bearer token from spike-get-token' responseType: 'stream', };

return request(options);

yonatandt commented 3 years ago

Update: approval was down. Wait for it to be up before continuing to investigate the bug .

Shahar-Y commented 3 years ago

@ItayMarder please check on @yonatandt 's comment

yonatandt commented 3 years ago

Found the cause of the BUG.

Usually when there are no permission, Unauthorized (or rather Forbidden) status should be sent. In this case, a permit can suffice (for external users), but because an AbortWithStatus is already called in the HandleUserFilePermission during the download, GIN is not able to override the status code with OK therefore the requested file is sent back but with a Unauthorized status