From 382f3f5ddc24250f427d78a48003e51b2784efe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=B1nar?= <107423523+ThecoderPinar@users.noreply.github.com> Date: Tue, 10 Jun 2025 18:36:33 +0300 Subject: [PATCH] Protect API endpoints --- Controllers/OrderDetailsController.cs | 8 +++++--- Controllers/OrdersController.cs | 8 +++++--- Controllers/UsersController.cs | 8 +++++--- README.md | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Controllers/OrderDetailsController.cs b/Controllers/OrderDetailsController.cs index 1ea0161..d597f21 100644 --- a/Controllers/OrderDetailsController.cs +++ b/Controllers/OrderDetailsController.cs @@ -4,12 +4,14 @@ using CoreXCrud.Repositories; using FluentValidation; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; namespace CoreXCrud.Controllers { - [Route("api/[controller]")] - [ApiController] - public class OrderDetailsController : ControllerBase +[Authorize] // 📌 JWT ile yetkilendirme ekledik +[Route("api/[controller]")] +[ApiController] +public class OrderDetailsController : ControllerBase { private readonly IUnitOfWork _unitOfWork; private readonly IMapper _mapper; diff --git a/Controllers/OrdersController.cs b/Controllers/OrdersController.cs index a0d93f4..2fb4dc2 100644 --- a/Controllers/OrdersController.cs +++ b/Controllers/OrdersController.cs @@ -4,13 +4,15 @@ using CoreXCrud.Repositories; using FluentValidation; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; using Serilog; namespace CoreXCrud.Controllers { - [Route("api/[controller]")] - [ApiController] - public class OrdersController : ControllerBase +[Authorize] // 📌 JWT ile yetkilendirme ekledik +[Route("api/[controller]")] +[ApiController] +public class OrdersController : ControllerBase { private readonly IUnitOfWork _unitOfWork; private readonly IMapper _mapper; diff --git a/Controllers/UsersController.cs b/Controllers/UsersController.cs index 1c6e375..f6aeb4a 100644 --- a/Controllers/UsersController.cs +++ b/Controllers/UsersController.cs @@ -4,12 +4,14 @@ using CoreXCrud.Repositories; using FluentValidation; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; namespace CoreXCrud.Controllers { - [Route("api/[controller]")] - [ApiController] - public class UsersController : ControllerBase +[Authorize] // 📌 JWT ile yetkilendirme ekledik +[Route("api/[controller]")] +[ApiController] +public class UsersController : ControllerBase { private readonly IUnitOfWork _unitOfWork; private readonly IMapper _mapper; diff --git a/README.md b/README.md index 2dc24a9..e0efc36 100644 --- a/README.md +++ b/README.md @@ -177,9 +177,11 @@ https://localhost:7252/swagger ---------- -## 📊 API Modülleri ve Uç Noktalar - -### 🧑‍💼 1️⃣ Kullanıcı Yönetimi (Users) +## 📊 API Modülleri ve Uç Noktalar + +> **Not:** `/api/Auth/login` haricindeki tüm uç noktalar JWT ile korunur. İsteklerinizde `Authorization: Bearer {token}` başlığını göndermeniz gerekir. + +### 🧑‍💼 1️⃣ Kullanıcı Yönetimi (Users) Kullanıcı yönetimi API'si, sistemdeki kullanıcıları yönetmek için kullanılır.