Add access control for media downloads

Introduced IAccesserToDownloadMedia and its implementation to enforce access checks when downloading media files. Updated MediaController to use the new accesser service and improved error handling and validation in upload/download actions. Refactored and moved MediaService to the Medias namespace, registered new services in DI, and added comprehensive tests for access logic. Also fixed GroupMembershipConfiguration to make InvitationId optional and performed minor test and namespace cleanups.
This commit is contained in:
Artemy
2025-07-21 14:51:57 +07:00
parent 58e7716ded
commit c0d02e0fa1
11 changed files with 243 additions and 30 deletions
@@ -11,6 +11,7 @@ using Govor.Application.Interfaces.UserSession;
using Govor.Application.Services;
using Govor.Application.Services.Authentication;
using Govor.Application.Services.Friends;
using Govor.Application.Services.Medias;
using Govor.Application.Services.Messages;
using Govor.Application.Services.UserSessions;
using Govor.Core.Infrastructure.Extensions;
@@ -68,6 +69,7 @@ public static class ConfigurationProgramExtensions
services.AddScoped<IUserGroupsService, UserGroupsService>();
services.AddScoped<IMessagesLoader, MessagesLoader>();
services.AddScoped<IMediaService, MediaService>();
services.AddScoped<IAccesserToDownloadMedia, AccesserToDownloadMediaService>();
// UserSession
services.AddScoped<IUserSessionOpener, UserSessionOpener>();