Files
k-photos/libertas_api/src/state.rs
Gabriel Kaszewski 8d05bdfd63 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`.
2025-11-15 14:01:39 +01:00

22 lines
660 B
Rust

use std::sync::Arc;
use libertas_core::{
config::AppConfig,
services::{AlbumService, AuthorizationService, MediaService, PersonService, TagService, UserService},
};
use crate::security::TokenGenerator;
#[derive(Clone)]
pub struct AppState {
pub user_service: Arc<dyn UserService>,
pub media_service: Arc<dyn MediaService>,
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,
}