diff --git a/src/services/authorization.rs b/src/services/authorization.rs index 72ae5679..9419b216 100644 --- a/src/services/authorization.rs +++ b/src/services/authorization.rs @@ -45,6 +45,7 @@ pub enum ACTION { GetLicensePage, GetImageByUrl, GetPublicSettings, + GetTorrent, AddTorrent, } @@ -185,17 +186,20 @@ impl CasbinConfiguration { admin, DeleteTorrent admin, BanUser admin, GetImageByUrl + admin, GetTorrent admin, AddTorrent registered, GetCategories registered, GetImageByUrl registered, GetPublicSettings registered, GetTags + registered, GetTorrent registered, AddTorrent guest, GetCategories guest, GetTags guest, GetAboutPage guest, GetLicensePage guest, GetPublicSettings + guest, GetTorrent ", ), } diff --git a/src/services/torrent.rs b/src/services/torrent.rs index c71ffc18..5d5464b9 100644 --- a/src/services/torrent.rs +++ b/src/services/torrent.rs @@ -263,6 +263,8 @@ impl Index { /// This function will return an error if unable to get the torrent from the /// database. pub async fn get_torrent(&self, info_hash: &InfoHash, opt_user_id: Option) -> Result { + self.authorization_service.authorize(ACTION::GetTorrent, opt_user_id).await?; + let mut torrent = self.torrent_repository.get_by_info_hash(info_hash).await?; let tracker_url = self.get_tracker_url().await;