Implement authorization service and refactor services to use it

- Added `AuthorizationService` and its implementation `AuthorizationServiceImpl` to handle permission checks across various services.
- Refactored `AlbumServiceImpl`, `MediaServiceImpl`, `PersonServiceImpl`, and `TagServiceImpl` to utilize the new authorization service for permission checks.
- Removed direct permission checks from services and replaced them with calls to the `AuthorizationService`.
- Updated repository interfaces to include new methods for checking media permissions in shared albums.
- Enhanced the `authz` module with new permission types for better granularity in access control.
- Adjusted the `AppState` struct to include the new `authorization_service`.
This commit is contained in:
2025-11-15 14:01:39 +01:00
parent ac8d16ba59
commit 8d05bdfd63
12 changed files with 547 additions and 292 deletions

View File

@@ -2,7 +2,7 @@ use std::sync::Arc;
use libertas_core::{
config::AppConfig,
services::{AlbumService, MediaService, PersonService, TagService, UserService},
services::{AlbumService, AuthorizationService, MediaService, PersonService, TagService, UserService},
};
use crate::security::TokenGenerator;
@@ -14,6 +14,7 @@ pub struct AppState {
pub album_service: Arc<dyn AlbumService>,
pub tag_service: Arc<dyn TagService>,
pub person_service: Arc<dyn PersonService>,
pub authorization_service: Arc<dyn AuthorizationService>,
pub token_generator: Arc<dyn TokenGenerator>,
pub nats_client: async_nats::Client,
pub config: AppConfig,