Ajout des droits RH dans l'API formation

develop
jboinembalome 3 years ago
parent 3190add127
commit f056c41133
  1. 21
      EPAServeur/Controllers/FormationsApi.cs

@ -27,6 +27,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authentication.JwtBearer;
namespace IO.Swagger.Controllers
{
@ -59,7 +60,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPost]
[Route("/api/formations")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("AddFormation")]
[SwaggerResponse(statusCode: 201, type: typeof(FormationDTO), description: "Formation créée avec succès")]
@ -132,7 +133,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpDelete]
[Route("/api/formations/{idFormation}")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("DeleteFormation")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;est pas authentifié")]
@ -216,7 +217,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/formations/{idFormation}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetFormationById")]
[SwaggerResponse(statusCode: 200, type: typeof(FormationDTO), description: "OK")]
@ -286,7 +287,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/formations")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetFormations")]
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), description: "OK")]
@ -342,7 +343,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/formations/count")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetFormationsCount")]
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")]
@ -390,7 +391,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/modesformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetModesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<ModeFormationDTO>), description: "OK")]
@ -437,7 +438,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/originesformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetOriginesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineFormationDTO>), description: "OK")]
@ -484,7 +485,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/statutsformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetStatutsFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<StatutFormationDTO>), description: "OK")]
@ -531,7 +532,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/typesformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("GetTypesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<TypeFormationDTO>), description: "OK")]
@ -582,7 +583,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/formations/{idFormation}")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")]
[ValidateModelState]
[SwaggerOperation("UpdateFormation")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;est pas authentifié")]

Loading…
Cancel
Save