implementation of Authentication using JWT. Security applied on all microservices endpoints.

This commit is contained in:
Reginald Cherenfant Jasmin
2023-09-20 00:32:30 -04:00
parent 8d386af40a
commit 77816605d1
75 changed files with 1744 additions and 219 deletions

View File

@ -2,6 +2,7 @@
using DamageAssesment.Api.Documents.Interfaces;
using DamageAssesment.Api.Documents.Models;
using DamageAssesment.Api.Documents.Providers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -24,6 +25,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// Get all document link type.
/// </summary>
[HttpGet]
[Authorize(Roles = "admin")]
[Route("doculinks/types")]
public async Task<IActionResult> GetLinkTypesAsync()
{
@ -37,6 +39,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Get a document link type by id.
/// </summary>
[Authorize(Roles = "admin")]
[HttpGet]
[Route("doculinks/types/{id}")]
public async Task<IActionResult> GetLinkTypeAsync(int id)
@ -51,6 +54,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Update a existing document link type.
/// </summary>
[Authorize(Roles = "admin")]
[HttpPut]
[Route("doculinks/types")]
public async Task<IActionResult> UpdateLinkType(Models.LinkType linkType)
@ -72,6 +76,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Create a new document link type.
/// </summary>
[Authorize(Roles = "admin")]
[HttpPost]
[Route("doculinks/types")]
public async Task<IActionResult> CreateLinkType(Models.LinkType linkType)
@ -90,6 +95,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Delete a existing document link type by id.
/// </summary>
[Authorize(Roles = "admin")]
[HttpDelete]
[Route("doculinks/types/{id}")]
public async Task<IActionResult> DeleteLinkType(int id)
@ -101,11 +107,12 @@ namespace DamageAssesment.Api.Documents.Controllers
}
return NotFound();
}
/// <summary>
/// Get all documents.
/// </summary>
///
[Route("doculinks")]
/// <summary>
/// Get all documents.
/// </summary>
[Authorize(Roles = "admin")]
[Route("doculinks")]
[Route("doculinks/{linktype:alpha}")]
[Route("doculinks/{linktype:alpha}/{language:alpha}")]
[HttpGet]
@ -138,6 +145,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Get a document by id.
/// </summary>
[Authorize(Roles = "admin")]
[HttpGet]
[Route("doculinks/{id}")]
[Route("doculinks/{id}/{linktype:alpha}")]
@ -154,6 +162,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Upload new document.
/// </summary>
[Authorize(Roles = "admin")]
[HttpPut]
[Route("doculinks/{id}")]
public async Task<IActionResult> UpdateDocument(int id,DocumentInfo documentInfo)
@ -178,6 +187,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// update existing document.
/// </summary>
[Authorize(Roles = "admin")]
[HttpPost]
[Route("doculinks")]
public async Task<IActionResult> CreateDocument(DocumentInfo documentInfo)
@ -205,6 +215,7 @@ namespace DamageAssesment.Api.Documents.Controllers
/// <summary>
/// Delete document by id.
/// </summary>
[Authorize(Roles = "admin")]
[HttpDelete]
[Route("doculinks/{id}")]
public async Task<IActionResult> DeleteDocument(int id)