Skip to content

Commit f8e7570

Browse files
committed
feat: [#615] authorization layer added to the get torrent info method of the torrent service
1 parent 1342dce commit f8e7570

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/services/authorization.rs

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum ACTION {
4949
AddTorrent,
5050
GetCanonicalInfoHash,
5151
GenerateTorrentInfoListing,
52+
GetTorrentInfo,
5253
}
5354

5455
pub struct Service {
@@ -192,6 +193,7 @@ impl CasbinConfiguration {
192193
admin, AddTorrent
193194
admin, GetCanonicalInfoHash
194195
admin, GenerateTorrentInfoListing
196+
admin, GetTorrentInfo
195197
registered, GetCategories
196198
registered, GetImageByUrl
197199
registered, GetPublicSettings
@@ -200,6 +202,7 @@ impl CasbinConfiguration {
200202
registered, AddTorrent
201203
registered, GetCanonicalInfoHash
202204
registered, GenerateTorrentInfoListing
205+
registered, GetTorrentInfo
203206
guest, GetCategories
204207
guest, GetTags
205208
guest, GetAboutPage
@@ -208,6 +211,7 @@ impl CasbinConfiguration {
208211
guest, GetTorrent
209212
guest, GetCanonicalInfoHash
210213
guest, GenerateTorrentInfoListing
214+
guest, GetTorrentInfo
211215
",
212216
),
213217
}

src/services/torrent.rs

+4
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ impl Index {
333333
info_hash: &InfoHash,
334334
opt_user_id: Option<UserId>,
335335
) -> Result<TorrentResponse, ServiceError> {
336+
self.authorization_service
337+
.authorize(ACTION::GetTorrentInfo, opt_user_id)
338+
.await?;
339+
336340
let torrent_listing = self.torrent_listing_generator.one_torrent_by_info_hash(info_hash).await?;
337341

338342
let torrent_response = self

0 commit comments

Comments
 (0)