feat: Enhance Hackathon Timeline Management and Admin Features

- Updated HackathonTimelineCreateRequestDto to accept optional title and name fields.
- Added custom validators for HackathonPhase and date checks in hackathon_dto.rs.
- Implemented admin-sensitive data management DTOs for handling user scores and personal info.
- Introduced new admin routes for managing users, roles, and permissions in IAM module.
- Added timeline enforcement middleware to restrict access based on hackathon phases.
- Created tests for timeline enforcement and admin permissions to ensure proper access control.
- Implemented payment middleware as a placeholder for future payment processing logic.
- Enhanced audit logging middleware for improved error handling and logging.
This commit is contained in:
MythEclipse
2025-10-13 10:57:53 +07:00
parent 6f596efadd
commit 6915a97d79
28 changed files with 1331 additions and 114 deletions
@@ -0,0 +1,59 @@
use axum::{
body::Body,
http::{Request, Response},
};
use futures::future::BoxFuture;
use imphnen_libs::AppState;
use std::task::{Context, Poll};
use tower::{Layer, Service};
/// Placeholder middleware layer for payment processing.
/// Currently a pass-through implementation.
#[derive(Clone)]
pub struct PaymentLayer {
app_state: AppState,
}
impl PaymentLayer {
/// Create a new payment middleware layer
pub fn new(app_state: AppState) -> Self {
Self { app_state }
}
}
impl<S> Layer<S> for PaymentLayer {
type Service = PaymentMiddleware<S>;
fn layer(&self, inner: S) -> Self::Service {
PaymentMiddleware {
inner,
app_state: self.app_state.clone(),
}
}
}
#[derive(Clone)]
pub struct PaymentMiddleware<S> {
inner: S,
app_state: AppState,
}
impl<S> Service<Request<Body>> for PaymentMiddleware<S>
where
S: Service<Request<Body>, Response = Response<Body>, Error = Response<Body>> + Clone + Send + 'static,
S::Future: Send + 'static,
{
type Response = S::Response;
type Error = S::Error;
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_ready(cx)
}
fn call(&mut self, req: Request<Body>) -> Self::Future {
let mut inner = self.inner.clone();
let _app_state = self.app_state.clone();
Box::pin(async move {
// TODO: Implement payment validation logic here
inner.call(req).await
})
}
}