Added initial authorization layer.

This commit is contained in:
2026-10-09 17:22:46 +02:00
parent 7fb3abc93d
commit 1f6de34e5b
16 changed files with 184 additions and 64 deletions
+6 -5
View File
@@ -5,12 +5,9 @@ use uuid::Uuid;
use super::{
dtos::user::{UserRequest, UserResponse},
extractors::{json::Json, path::Path, query::Query},
};
use crate::{
error::AppError,
repository::{self},
extractors::{auth::Auth, json::Json, path::Path, query::Query},
};
use crate::{error::AppError, repository};
pub fn create_router() -> axum::Router<PgPool> {
axum::Router::new()
@@ -32,6 +29,7 @@ pub struct QueryParams {
#[axum::debug_handler]
#[tracing::instrument(skip(pool))]
async fn list_users(
Auth(auth): Auth,
State(pool): State<PgPool>,
Query(query): Query<QueryParams>,
) -> Result<Json<Vec<UserResponse>>, AppError> {
@@ -52,6 +50,7 @@ async fn list_users(
#[axum::debug_handler]
#[tracing::instrument(skip(pool))]
async fn get_user(
Auth(auth): Auth,
State(pool): State<PgPool>,
Path(id): Path<Uuid>,
) -> Result<Json<UserResponse>, AppError> {
@@ -65,6 +64,7 @@ async fn get_user(
#[axum::debug_handler]
#[tracing::instrument(skip(pool, user))]
async fn upsert_user(
Auth(auth): Auth,
State(pool): State<PgPool>,
Path(id): Path<Uuid>,
Json(user): Json<UserRequest>,
@@ -84,6 +84,7 @@ async fn upsert_user(
#[axum::debug_handler]
#[tracing::instrument(skip(pool))]
async fn delete_user(
Auth(auth): Auth,
Path(id): Path<Uuid>,
State(pool): State<PgPool>,
) -> Result<StatusCode, AppError> {