Add authorization check for downloading attachments in handleRequest method
This commit is contained in:
parent
cb5862fe94
commit
3217100cff
1 changed files with 6 additions and 6 deletions
|
@ -18,6 +18,12 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
|
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
||||||
|
if(!Configuration::getServerConfiguration()->isEvidencePublic() && $authenticatedOperator === null)
|
||||||
|
{
|
||||||
|
throw new RequestException('Unauthorized: You must be authenticated to download attachments', 401);
|
||||||
|
}
|
||||||
|
|
||||||
if(!preg_match('#^/attachments/([a-fA-F0-9\-]{36,})$#', FederationServer::getPath(), $matches))
|
if(!preg_match('#^/attachments/([a-fA-F0-9\-]{36,})$#', FederationServer::getPath(), $matches))
|
||||||
{
|
{
|
||||||
throw new RequestException('Attachment UUID required', 405);
|
throw new RequestException('Attachment UUID required', 405);
|
||||||
|
@ -29,12 +35,6 @@
|
||||||
throw new RequestException('Invalid attachment UUID', 400);
|
throw new RequestException('Invalid attachment UUID', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
|
||||||
if(!Configuration::getServerConfiguration()->isEvidencePublic() && $authenticatedOperator === null)
|
|
||||||
{
|
|
||||||
throw new RequestException('Unauthorized: You must be authenticated to download attachments', 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$attachment = FileAttachmentManager::getRecord($attachmentUuid);
|
$attachment = FileAttachmentManager::getRecord($attachmentUuid);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue