Ignore:
Timestamp:
10/26/25 20:52:35 (11 months ago)
Author:
stefansaveski <stefansaveski19@…>
Branches:
master
Children:
3347c1b, c2e73b6, cab02ad
Parents:
9538edc
Message:

Add JWT authentication and refactor namespaces

Introduced JWT-based authentication and authorization:

  • Configured JWT authentication in Program.cs with token validation.
  • Added [Authorize] attribute to a new getstring endpoint.

Refactored namespaces for consistency:

  • Updated namespaces from iknow_api.Core.* to iknow_api.*.

Enhanced middleware and dependency injection:

  • Registered IAuthService and IUserRepository.
  • Added app.UseAuthentication() and app.UseAuthorization().

Removed unused code and dependencies:

  • Deleted WeatherForecast class.
  • Cleaned up redundant imports.

Updated project dependencies to include JWT authentication library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Controllers/AuthController.cs

    r9538edc re49c3ed  
    11using iknow_api.DTOs;
    22using iknow_api.Services;
     3using Microsoft.AspNetCore.Authorization;
     4using Microsoft.AspNetCore.Authentication.JwtBearer;
    35using Microsoft.AspNetCore.Mvc;
    46
     
    4547            return Ok(new { Token = token });
    4648        }
     49
     50        [Authorize]
     51        [HttpGet("getstring")]
     52        public async Task<IActionResult> getstring()
     53        {
     54            return Ok(new { message = "You are authorized!" });
     55        }
    4756    }
    4857}
Note: See TracChangeset for help on using the changeset viewer.