From f8e75709c1a04d1ae4754f26f810236fb262d0fc Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 17 Jul 2024 23:18:08 +0200 Subject: [PATCH] feat: [#615] authorization layer added to the get torrent info method of the torrent service --- src/services/authorization.rs | 4 ++++ src/services/torrent.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/services/authorization.rs b/src/services/authorization.rs index fac7d1cb..5d5c8bc7 100644 --- a/src/services/authorization.rs +++ b/src/services/authorization.rs @@ -49,6 +49,7 @@ pub enum ACTION { AddTorrent, GetCanonicalInfoHash, GenerateTorrentInfoListing, + GetTorrentInfo, } pub struct Service { @@ -192,6 +193,7 @@ impl CasbinConfiguration { admin, AddTorrent admin, GetCanonicalInfoHash admin, GenerateTorrentInfoListing + admin, GetTorrentInfo registered, GetCategories registered, GetImageByUrl registered, GetPublicSettings @@ -200,6 +202,7 @@ impl CasbinConfiguration { registered, AddTorrent registered, GetCanonicalInfoHash registered, GenerateTorrentInfoListing + registered, GetTorrentInfo guest, GetCategories guest, GetTags guest, GetAboutPage @@ -208,6 +211,7 @@ impl CasbinConfiguration { guest, GetTorrent guest, GetCanonicalInfoHash guest, GenerateTorrentInfoListing + guest, GetTorrentInfo ", ), } diff --git a/src/services/torrent.rs b/src/services/torrent.rs index c1ee4125..5e118270 100644 --- a/src/services/torrent.rs +++ b/src/services/torrent.rs @@ -333,6 +333,10 @@ impl Index { info_hash: &InfoHash, opt_user_id: Option, ) -> Result { + self.authorization_service + .authorize(ACTION::GetTorrentInfo, opt_user_id) + .await?; + let torrent_listing = self.torrent_listing_generator.one_torrent_by_info_hash(info_hash).await?; let torrent_response = self