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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user